diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 17554a4a..41337e5e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -16,3 +16,16 @@ jobs: uses: ludeeus/action-shellcheck@1.1.0 with: scandir: './bin' + rubocop: + runs-on: ubuntu-latest + env: + BUNDLE_WITHOUT: development:test + + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + - name: Run tests + run: bundle exec rake rubocop diff --git a/.gitignore b/.gitignore index 1f85efba..3055395b 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ # Ignore bundler config. /.bundle /vendor +/.vendor # Ignore the default SQLite database. /db/*.sqlite3 diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000..d3eabd85 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,13 @@ +--- +inherit_from: .rubocop_todo.yml + +require: rubocop-rails + +AllCops: + TargetRubyVersion: 2.5 + NewCops: enable + Include: + - '**/*.rb' + Exclude: + - vendor/**/* + - .vendor/**/* diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml new file mode 100644 index 00000000..501d2c79 --- /dev/null +++ b/.rubocop_todo.yml @@ -0,0 +1,702 @@ +--- +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2022-04-07 09:17:26 UTC using RuboCop version 1.25.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 12 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_argument, with_fixed_indentation +Layout/ArgumentAlignment: + Exclude: + - 'app/controllers/keys_controller.rb' + - 'app/models/hiera_data/data_file.rb' + - 'bin/webpack' + - 'bin/webpack-dev-server' + - 'test/controllers/keys_controller_test.rb' + - 'test/integration/required_authentication_test.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: with_first_element, with_fixed_indentation +Layout/ArrayAlignment: + Exclude: + - 'app/services/puppet_db_client.rb' + - 'config/initializers/friendly_id.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. +# SupportedStyles: case, end +Layout/CaseIndentation: + Exclude: + - 'app/helpers/application_helper.rb' + +# Offense count: 12 +# Cop supports --auto-correct. +Layout/EmptyLineAfterGuardClause: + Exclude: + - 'app/models/hiera_data/config.rb' + - 'app/models/hiera_data/hierarchy.rb' + - 'app/models/hiera_data/interpolation.rb' + - 'app/models/hiera_data/yaml_file.rb' + - 'bin/bundle' + - 'test/support/fake_puppet_db.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'test/models/hiera_data/config_test.rb' + - 'test/models/hiera_data/hierarchy_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/EmptyLines: + Exclude: + - 'test/models/hiera_data/hierarchy_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: around, only_before +Layout/EmptyLinesAroundAccessModifier: + Exclude: + - 'app/controllers/users_controller.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'app/models/hiera_data.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, no_empty_lines +Layout/EmptyLinesAroundBlockBody: + Exclude: + - 'db/schema.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only +Layout/EmptyLinesAroundClassBody: + Exclude: + - 'test/controllers/sessions_controller_test.rb' + - 'test/integration/required_authentication_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines +Layout/EmptyLinesAroundModuleBody: + Exclude: + - 'app/models/hiera_data/interpolation.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. +Layout/ExtraSpacing: + Exclude: + - 'test/models/hiera_data_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: special_inside_parentheses, consistent, align_brackets +Layout/FirstArrayElementIndentation: + Exclude: + - 'test/models/hiera_data_test.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle. +# SupportedHashRocketStyles: key, separator, table +# SupportedColonStyles: key, separator, table +# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit +Layout/HashAlignment: + Exclude: + - 'app/models/user.rb' + - 'test/models/key_test.rb' + - 'test/models/node_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/HeredocIndentation: + Exclude: + - 'test/models/hiera_data/yaml_file_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'app/controllers/users_controller.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + +# Offense count: 4 +# Cop supports --auto-correct. +# Configuration parameters: Width, IgnoredPatterns. +Layout/IndentationWidth: + Exclude: + - 'app/controllers/users_controller.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: symmetrical, new_line, same_line +Layout/MultilineArrayBraceLayout: + Exclude: + - 'app/services/puppet_db_client.rb' + +# Offense count: 8 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented, indented_relative_to_receiver +Layout/MultilineMethodCallIndentation: + Exclude: + - 'app/models/hiera_data/data_file.rb' + - 'app/models/hiera_data/hierarchy.rb' + - 'app/models/key.rb' + - 'test/support/fake_puppet_db.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, IndentationWidth. +# SupportedStyles: aligned, indented +Layout/MultilineOperationIndentation: + Exclude: + - 'bin/bundle' + +# Offense count: 9 +# Cop supports --auto-correct. +Layout/SpaceAfterComma: + Exclude: + - 'config/environments/development.rb' + - 'config/environments/test.rb' + - 'test/support/fake_puppet_db.rb' + +# Offense count: 13 +# Cop supports --auto-correct. +# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. +# SupportedStylesForExponentOperator: space, no_space +Layout/SpaceAroundOperators: + Exclude: + - 'app/models/hiera_data/yaml_file.rb' + - 'test/models/hiera_data/data_file_test.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + - 'test/models/hiera_data_test.rb' + - 'test/models/node_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Layout/SpaceBeforeComma: + Exclude: + - 'app/models/node.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'config/environments/production.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. +# SupportedStyles: space, no_space +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideBlockBraces: + Exclude: + - 'app/models/hiera_data/interpolation.rb' + +# Offense count: 67 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBraces: space, no_space +Layout/SpaceInsideHashLiteralBraces: + Exclude: + - 'config/routes.rb' + - 'test/models/hiera_data/data_file_test.rb' + - 'test/models/hiera_data/hierarchy_test.rb' + - 'test/models/hiera_data/interpolation_test.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + - 'test/models/hiera_data_test.rb' + - 'test/models/key_test.rb' + - 'test/models/node_test.rb' + - 'test/support/fake_puppet_db.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'config/initializers/friendly_id.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/AmbiguousRegexpLiteral: + Exclude: + - 'test/models/hiera_data_test.rb' + +# Offense count: 2 +# Configuration parameters: AllowSafeAssignment. +Lint/AssignmentInCondition: + Exclude: + - 'app/models/hiera_data/data_file.rb' + - 'app/models/hiera_data/git_repo.rb' + +# Offense count: 5 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'config/environments/development.rb' + - 'config/environments/production.rb' + - 'config/environments/test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/DeprecatedClassMethods: + Exclude: + - 'app/models/hiera_data/git_repo.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments. +Lint/EmptyFile: + Exclude: + - 'config/initializers/cancan.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +Lint/ScriptPermission: + Exclude: + - 'test/fixtures/files/puppet/environments/eyaml/generate_eyaml_entries.rb' + - 'test/fixtures/files/puppet/generate_nodes.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. +Lint/UnusedBlockArgument: + Exclude: + - 'app/models/key.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 3 +# Configuration parameters: IgnoredMethods, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 27 + +# Offense count: 1 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +# IgnoredMethods: refine +Metrics/BlockLength: + Max: 27 + +# Offense count: 1 +# Configuration parameters: CountComments, CountAsOne. +Metrics/ClassLength: + Max: 109 + +# Offense count: 2 +# Configuration parameters: IgnoredMethods. +Metrics/CyclomaticComplexity: + Max: 9 + +# Offense count: 16 +# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods. +Metrics/MethodLength: + Max: 22 + +# Offense count: 2 +# Configuration parameters: CountKeywordArgs, MaxOptionalParameters. +Metrics/ParameterLists: + Max: 8 + +# Offense count: 1 +# Configuration parameters: IgnoredMethods. +Metrics/PerceivedComplexity: + Max: 9 + +# Offense count: 1 +# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros. +# NamePrefix: is_, has_, have_ +# ForbiddenPrefixes: is_, has_, have_ +# AllowedMethods: is_a? +# MethodDefinitionMacros: define_method, define_singleton_method +Naming/PredicateName: + Exclude: + - 'app/models/hiera_data/yaml_file.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: PreferredName. +Naming/RescuedExceptionsVariableName: + Exclude: + - 'app/models/hiera_data/config.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: NilOrEmpty, NotPresent, UnlessPresent. +Rails/Blank: + Exclude: + - 'app/models/ability.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. +# Whitelist: find_by_sql +# AllowedMethods: find_by_sql +# AllowedReceivers: Gem::Specification +Rails/DynamicFindBy: + Exclude: + - 'app/controllers/sessions_controller.rb' + +# Offense count: 9 +# Configuration parameters: EnforcedStyle. +# SupportedStyles: slashes, arguments +Rails/FilePath: + Exclude: + - 'config/environments/development.rb' + - 'test/models/hiera_data/data_file_test.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + - 'test/models/hiera_data_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: NotNilAndNotEmpty, NotBlank, UnlessBlank. +Rails/Present: + Exclude: + - 'bin/bundle' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, Include. +# SupportedStyles: assert_not, refute +# Include: **/test/**/* +Rails/RefuteMethods: + Exclude: + - 'test/models/hiera_data/hierarchy_test.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + - 'test/models/hierarchy_test.rb' + - 'test/models/user_test.rb' + +# Offense count: 5 +# Configuration parameters: Include. +# Include: db/**/*.rb +Rails/ReversibleMigration: + Exclude: + - 'db/migrate/20210326144242_drop_puppet_tables.rb' + +# Offense count: 11 +# Cop supports --auto-correct. +Security/YAMLLoad: + Exclude: + - 'app/models/hiera_data/config.rb' + - 'app/models/hiera_data/yaml_file.rb' + - 'app/models/key.rb' + - 'test/models/hiera_data/data_file_test.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + - 'test/models/hiera_data_test.rb' + - 'test/support/fake_puppet_db.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ProceduralMethods, FunctionalMethods, IgnoredMethods, AllowBracesOnProceduralOneLiners, BracesRequiredMethods. +# SupportedStyles: line_count_based, semantic, braces_for_chaining, always_braces +# ProceduralMethods: benchmark, bm, bmbm, create, each_with_object, measure, new, realtime, tap, with_object +# FunctionalMethods: let, let!, subject, watch +# IgnoredMethods: lambda, proc, it +Style/BlockDelimiters: + Exclude: + - 'test/fixtures/files/puppet/environments/eyaml/generate_eyaml_entries.rb' + - 'test/fixtures/files/puppet/generate_nodes.rb' + +# Offense count: 16 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: nested, compact +Style/ClassAndModuleChildren: + Exclude: + - 'test/channels/application_cable/connection_test.rb' + - 'test/models/hiera_data/config_test.rb' + - 'test/models/hiera_data/data_file_test.rb' + - 'test/models/hiera_data/git_repo_test.rb' + - 'test/models/hiera_data/hierarchy_test.rb' + - 'test/models/hiera_data/interpolation_test.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + - 'test/test_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerBackticks. +# SupportedStyles: backticks, percent_x, mixed +Style/CommandLiteral: + Exclude: + - 'test/fixtures/files/puppet/environments/eyaml/generate_eyaml_entries.rb' + +# Offense count: 45 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/ExpandPathArguments: + Exclude: + - 'bin/bundle' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/FileWrite: + Exclude: + - 'test/fixtures/files/puppet/generate_nodes.rb' + +# Offense count: 1 +# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, IgnoredMethods. +# SupportedStyles: annotated, template, unannotated +Style/FormatStringToken: + EnforcedStyle: template + +# Offense count: 109 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Enabled: false + +# Offense count: 1 +# Cop supports --auto-correct. +Style/GlobalStdStream: + Exclude: + - 'config/environments/production.rb' + +# Offense count: 7 +# Configuration parameters: MinBodyLength. +Style/GuardClause: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/page_controller.rb' + - 'app/controllers/sessions_controller.rb' + - 'app/models/hiera_data/data_file.rb' + - 'app/models/hiera_data/hierarchy.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowSplatArgument. +Style/HashConversion: + Exclude: + - 'test/support/fake_puppet_db.rb' + +# Offense count: 1 +# Configuration parameters: MinBranchesCount. +Style/HashLikeCase: + Exclude: + - 'app/helpers/application_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowIfModifier. +Style/IfInsideElse: + Exclude: + - 'app/controllers/users_controller.rb' + +# Offense count: 10 +# Cop supports --auto-correct. +Style/IfUnlessModifier: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/page_controller.rb' + - 'app/controllers/sessions_controller.rb' + - 'app/controllers/users_controller.rb' + - 'app/models/hiera_data/config.rb' + - 'app/models/hiera_data/hierarchy.rb' + - 'bin/bundle' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: literals, strict +Style/MutableConstant: + Exclude: + - 'app/models/value.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedOctalStyle. +# SupportedOctalStyles: zero_with_o, zero_only +Style/NumericLiteralPrefix: + Exclude: + - 'app/models/hiera_data/yaml_file.rb' + - 'test/models/hiera_data/hierarchy_test.rb' + - 'test/models/hiera_data/yaml_file_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: MinDigits, Strict, AllowedNumbers. +Style/NumericLiterals: + Exclude: + - 'db/schema.rb' + +# Offense count: 7 +# Cop supports --auto-correct. +# Configuration parameters: PreferredDelimiters. +Style/PercentLiteralDelimiters: + Exclude: + - 'app/models/hiera_data/hierarchy.rb' + - 'config/initializers/friendly_id.rb' + - 'test/models/environment_test.rb' + - 'test/models/hiera_data/hierarchy_test.rb' + - 'test/models/key_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/PerlBackrefs: + Exclude: + - 'bin/bundle' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: short, verbose +Style/PreferredHashMethods: + Exclude: + - 'app/models/hiera_data/data_file.rb' + - 'app/models/hiera_data/hierarchy.rb' + - 'app/models/hiera_data/yaml_file.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. +# SupportedStyles: compact, exploded +Style/RaiseArgs: + Exclude: + - 'app/models/hiera_data.rb' + - 'app/models/hiera_data/git_repo.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantBegin: + Exclude: + - 'test/test_helper.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantCondition: + Exclude: + - 'app/models/hiera_data/yaml_file.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: SafeForConstants. +Style/RedundantFetchBlock: + Exclude: + - 'config/puma.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantSelf: + Exclude: + - 'app/models/user.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowInnerSlashes. +# SupportedStyles: slashes, percent_r, mixed +Style/RegexpLiteral: + Exclude: + - 'config/routes.rb' + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: implicit, explicit +Style/RescueStandardError: + Exclude: + - 'app/models/hiera_data/config.rb' + - 'app/services/puppet_db_client.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'app/controllers/sessions_controller.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/SingleArgumentDig: + Exclude: + - 'app/services/puppet_db_client.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: RequireEnglish. +# SupportedStyles: use_perl_names, use_english_names +Style/SpecialGlobalVars: + EnforcedStyle: use_perl_names + +# Offense count: 2 +# Cop supports --auto-correct. +Style/StderrPuts: + Exclude: + - 'bin/yarn' + +# Offense count: 785 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Enabled: false + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: MinSize. +# SupportedStyles: percent, brackets +Style/SymbolArray: + EnforcedStyle: brackets + +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: percent + MinSize: 3 + +# Offense count: 2 +# Cop supports --auto-correct. +Style/ZeroLengthPredicate: + Exclude: + - 'test/fixtures/files/puppet/environments/eyaml/generate_eyaml_entries.rb' + - 'test/fixtures/files/puppet/generate_nodes.rb' + +# Offense count: 25 +# Cop supports --auto-correct. +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 3835 diff --git a/Gemfile b/Gemfile index 01a51714..2d693f01 100644 --- a/Gemfile +++ b/Gemfile @@ -55,6 +55,12 @@ group :test do gem 'webdrivers' end +group :linter do + gem 'rubocop' + gem 'rubocop-rails' + gem 'rubocop-rake' +end + # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] diff --git a/Gemfile.lock b/Gemfile.lock index bc313706..bbb8b151 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -63,6 +63,7 @@ GEM zeitwerk (~> 2.3) addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) + ast (2.4.2) bcrypt (3.1.17) bindex (0.8.1) breadcrumbs_on_rails (4.1.0) @@ -136,10 +137,26 @@ GEM nio4r (2.5.8) nokogiri (1.12.5-x86_64-darwin) racc (~> 1.4) + nokogiri (1.12.5-x86_64-linux) + racc (~> 1.4) optimist (3.0.1) + parallel (1.22.1) + parser (3.1.1.0) + ast (~> 2.4.1) public_suffix (4.0.6) puma (5.6.4) nio4r (~> 2.0) + puppet (7.15.0) + concurrent-ruby (~> 1.0) + deep_merge (~> 1.0) + facter (> 2.0.1, < 5) + fast_gettext (>= 1.1, < 3) + hiera (>= 3.2.1, < 4) + locale (~> 2.1) + multi_json (~> 1.10) + puppet-resource_api (~> 1.5) + scanf (~> 1.0) + semantic_puppet (~> 1.0) puppet (7.15.0-universal-darwin) CFPropertyList (~> 2.2) concurrent-ruby (~> 1.0) @@ -188,12 +205,32 @@ GEM method_source rake (>= 12.2) thor (~> 1.0) + rainbow (3.1.1) rake (13.0.6) rb-fsevent (0.11.1) rb-inotify (0.10.1) ffi (~> 1.0) rchardet (1.8.0) regexp_parser (2.2.1) + rexml (3.2.5) + rubocop (1.26.1) + parallel (~> 1.10) + parser (>= 3.1.0.0) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml + rubocop-ast (>= 1.16.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 1.4.0, < 3.0) + rubocop-ast (1.16.0) + parser (>= 3.1.1.0) + rubocop-rails (2.13.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.7.0, < 2.0) + rubocop-rake (0.6.0) + rubocop (~> 1.0) + ruby-progressbar (1.11.0) rubyzip (2.3.2) sass-rails (6.0.0) sassc-rails (~> 2.1, >= 2.1.1) @@ -232,6 +269,7 @@ GEM turbolinks-source (5.2.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) + unicode-display_width (2.1.0) web-console (4.2.0) actionview (>= 6.0.0) activemodel (>= 6.0.0) @@ -255,6 +293,7 @@ GEM PLATFORMS x86_64-darwin-21 + x86_64-linux DEPENDENCIES bcrypt (~> 3.1.7) @@ -273,6 +312,9 @@ DEPENDENCIES puppet puppetdb-ruby rails (~> 6.1.5, >= 6.1.0.0) + rubocop + rubocop-rails + rubocop-rake sass-rails (>= 6) selenium-webdriver simplecov diff --git a/Rakefile b/Rakefile index e85f9139..10249c3c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,6 +1,18 @@ # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. -require_relative 'config/application' +require 'rubocop/rake_task' +RuboCop::RakeTask.new(:rubocop) do |task| + # These make the rubocop experience maybe slightly less terrible + task.options = ['-D', '-S', '-E'] -Rails.application.load_tasks + # Use Rubocop's Github Actions formatter if possible + task.formatters << 'github' if ENV['GITHUB_ACTIONS'] == 'true' +end +# check if the rails configuration exists and load the tasks +if File.file?('config/hdm.yml') + require_relative 'config/application' + Rails.application.load_tasks +else + puts "Not loading Rails specific tasks because config/hdm.yml is missing!" +end