diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 81a73930..27d82eb6 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -7,8 +7,20 @@ env: DATABASE_URL: postgresql://postgres:@localhost/test DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL: true jobs: + rubocop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + - name: Run rubocop + run: bundle exec rubocop test_ruby: runs-on: ubuntu-latest + needs: rubocop services: postgres: image: postgres:12.1 diff --git a/.rubocop.yml b/.rubocop.yml index 5dfd1c5d..ed329360 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -7,8 +7,9 @@ inherit_from: - .rubocop_todo.yml AllCops: - TargetRubyVersion: 2.5 - TargetRailsVersion: 5.2 + TargetRubyVersion: 2.7 + TargetRailsVersion: 6.1 + NewCops: enable Include: - 'app/views/api/**/*.rabl' - 'app/**/*.rb' diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 390c240d..7a3d78d0 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,12 +1,12 @@ # This configuration was generated by # `rubocop --auto-gen-config` -# on 2020-04-17 15:41:13 +0200 using RuboCop version 0.80.1. +# on 2023-09-19 13:15:41 UTC using RuboCop version 1.23.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: 26 +# Offense count: 39 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: with_first_argument, with_fixed_indentation @@ -14,17 +14,23 @@ Layout/ArgumentAlignment: Exclude: - 'app/controllers/api/v2/discovered_hosts_controller.rb' - 'app/helpers/discovered_hosts_helper.rb' - - 'test/functional/api/v2/fact_value_extensions_test.rb' - - 'test/functional/discovered_hosts_controller_test.rb' + - 'app/services/foreman_discovery/lldp_neighbors.rb' + - 'test/factories/discovery_host_related.rb' - 'test/integration/discovered_hosts_test.rb' - 'test/test_helper_discovery.rb' - 'test/unit/discovered_extensions_test.rb' - 'test/unit/discovered_mailer_test.rb' - - 'test/unit/discovery_attribute_set_test.rb' - - 'test/unit/fact_parser_test.rb' - 'test/unit/host_discovered_test.rb' -# Offense count: 9 +# Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith. +# SupportedStylesAlignWith: either, start_of_block, start_of_line +Layout/BlockAlignment: + Exclude: + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth. # SupportedStyles: case, end @@ -42,7 +48,7 @@ Layout/ClosingParenthesisIndentation: - 'app/services/foreman_discovery/lldp_neighbors.rb' - 'test/unit/host_discovered_test.rb' -# Offense count: 21 +# Offense count: 22 # Cop supports --auto-correct. Layout/EmptyLineAfterGuardClause: Exclude: @@ -59,12 +65,20 @@ Layout/EmptyLineAfterGuardClause: - 'app/services/foreman_discovery/lldp_neighbors.rb' - 'app/services/foreman_discovery/node_api/node_resource.rb' -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. Layout/EmptyLineAfterMagicComment: Exclude: + - 'app/services/foreman_discovery/ui_notifications/failed_discovery.rb' - 'app/services/foreman_discovery/ui_notifications/new_host.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EmptyLineBetweenMethodDefs, EmptyLineBetweenClassDefs, EmptyLineBetweenModuleDefs, AllowAdjacentOneLineDefs, NumberOfEmptyLines. +Layout/EmptyLineBetweenDefs: + Exclude: + - 'test/unit/discovered_extensions_test.rb' + # Offense count: 1 # Cop supports --auto-correct. Layout/EmptyLines: @@ -79,7 +93,7 @@ Layout/EmptyLinesAroundBlockBody: Exclude: - 'lib/foreman_discovery/engine.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only @@ -87,7 +101,6 @@ Layout/EmptyLinesAroundClassBody: Exclude: - 'app/services/foreman_discovery/node_api/power_service.rb' - 'lib/foreman_discovery/engine.rb' - - 'test/functional/api/v2/discovered_hosts_controller_test.rb' - 'test/functional/discovery_rules_controller_test.rb' - 'test/unit/fact_parser_test.rb' @@ -99,13 +112,15 @@ Layout/EmptyLinesAroundModuleBody: Exclude: - 'app/controllers/concerns/foreman/controller/discovered_extensions.rb' -# Offense count: 6 +# Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment. Layout/ExtraSpacing: Exclude: - 'app/controllers/concerns/foreman/controller/discovered_extensions.rb' + - 'app/controllers/discovered_hosts_controller.rb' - 'app/helpers/discovered_hosts_helper.rb' + - 'test/functional/api/v2/discovered_hosts_controller_test.rb' - 'test/unit/ui_notifications/destroy_host_test.rb' - 'test/unit/ui_notifications/new_host_test.rb' @@ -126,7 +141,7 @@ Layout/FirstArgumentIndentation: Layout/FirstArrayElementIndentation: EnforcedStyle: consistent -# Offense count: 24 +# Offense count: 19 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, IndentationWidth. # SupportedStyles: special_inside_parentheses, consistent, align_braces @@ -141,19 +156,29 @@ Layout/FirstHashElementIndentation: # Offense count: 2 # Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: normal, indented_internal_methods +Layout/IndentationConsistency: + Exclude: + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 6 +# Cop supports --auto-correct. # Configuration parameters: Width, IgnoredPatterns. Layout/IndentationWidth: Exclude: - 'app/models/discovery_rule.rb' - - 'app/services/foreman_discovery/host_converter.rb' + - 'app/services/foreman_discovery/host_fact_importer.rb' + - 'lib/foreman_discovery/engine.rb' -# Offense count: 4 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: AllowDoxygenCommentStyle, AllowGemfileRubyComment. Layout/LeadingCommentSpace: Exclude: - 'app/controllers/discovery_rules_controller.rb' - 'lib/foreman_discovery/engine.rb' + - 'test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb' - 'test/unit/host_discovered_test.rb' # Offense count: 7 @@ -173,7 +198,7 @@ Layout/MultilineHashBraceLayout: Layout/MultilineMethodCallBraceLayout: Exclude: - 'app/helpers/discovered_hosts_helper.rb' - - 'test/test_helper_discovery.rb' + - 'app/models/discovery_rule.rb' - 'test/unit/discovered_mailer_test.rb' - 'test/unit/host_discovered_test.rb' @@ -194,7 +219,7 @@ Layout/MultilineOperationIndentation: Exclude: - 'app/helpers/discovered_hosts_helper.rb' -# Offense count: 13 +# Offense count: 18 # Cop supports --auto-correct. Layout/SpaceAfterComma: Exclude: @@ -208,7 +233,7 @@ Layout/SpaceAfterNot: Exclude: - 'app/lib/facter_utils.rb' -# Offense count: 10 +# Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. # SupportedStylesForExponentOperator: space, no_space @@ -220,7 +245,7 @@ Layout/SpaceAroundOperators: - 'app/helpers/discovered_hosts_helper.rb' - 'lib/foreman_discovery/engine.rb' -# Offense count: 7 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space @@ -228,6 +253,7 @@ Layout/SpaceAroundOperators: Layout/SpaceBeforeBlockBraces: Exclude: - 'app/models/host/discovered.rb' + - 'lib/foreman_discovery/engine.rb' - 'test/test_helper_discovery.rb' # Offense count: 3 @@ -236,15 +262,25 @@ Layout/SpaceBeforeComma: Exclude: - 'app/helpers/discovered_hosts_helper.rb' -# Offense count: 2 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment. Layout/SpaceBeforeFirstArg: Exclude: + - 'test/functional/api/v2/discovered_hosts_controller_test.rb' - 'test/unit/ui_notifications/destroy_host_test.rb' - 'test/unit/ui_notifications/new_host_test.rb' -# Offense count: 32 +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBrackets. +# SupportedStyles: space, no_space, compact +# SupportedStylesForEmptyBrackets: space, no_space +Layout/SpaceInsideArrayLiteralBrackets: + Exclude: + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 14 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. # SupportedStyles: space, no_space @@ -254,10 +290,11 @@ Layout/SpaceInsideBlockBraces: - 'app/controllers/discovered_hosts_controller.rb' - 'app/models/host/discovered.rb' - 'app/services/foreman_discovery/lldp_neighbors.rb' + - 'lib/foreman_discovery/engine.rb' - 'test/functional/api/v2/discovery_rules_controller_test.rb' - 'test/test_helper_discovery.rb' -# Offense count: 189 +# Offense count: 190 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. # SupportedStyles: space, no_space, compact @@ -265,21 +302,47 @@ Layout/SpaceInsideBlockBraces: Layout/SpaceInsideHashLiteralBraces: Enabled: false -# Offense count: 4 +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space +# SupportedStyles: space, compact, no_space Layout/SpaceInsideParens: Exclude: - 'app/controllers/discovered_hosts_controller.rb' - 'app/helpers/discovered_hosts_helper.rb' + - 'test/unit/discovery_rule_test.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'app/services/foreman_discovery/fact_to_category_resolver.rb' # Offense count: 3 +# Cop supports --auto-correct. +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'app/services/foreman_discovery/host_converter.rb' + - 'test/unit/discovered_extensions_test.rb' + +# Offense count: 5 +# Configuration parameters: IgnoredMethods. Lint/AmbiguousBlockAssociation: Exclude: + - 'lib/foreman_discovery/engine.rb' - 'test/functional/api/v2/discovery_rules_controller_test.rb' # Offense count: 2 +# Cop supports --auto-correct. +Lint/AmbiguousOperatorPrecedence: + Exclude: + - 'test/unit/discovery_rule_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. Lint/AmbiguousRegexpLiteral: Exclude: - 'test/functional/api/v2/discovery_rules_controller_test.rb' @@ -293,11 +356,37 @@ Lint/AssignmentInCondition: - 'app/controllers/discovered_hosts_controller.rb' # Offense count: 1 +# Cop supports --auto-correct. Lint/BooleanSymbol: Exclude: - 'app/models/discovery_rule.rb' +# Offense count: 2 +# Configuration parameters: AllowedMethods. +# AllowedMethods: enums +Lint/ConstantDefinitionInBlock: + Exclude: + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 2 +# Configuration parameters: IgnoreLiteralBranches, IgnoreConstantBranches. +Lint/DuplicateBranch: + Exclude: + - 'app/helpers/discovery_rules_helper.rb' + +# Offense count: 1 +# Configuration parameters: AllowComments, AllowEmptyLambdas. +Lint/EmptyBlock: + Exclude: + - 'app/services/foreman_discovery/host_converter.rb' + +# Offense count: 1 +Lint/MissingSuper: + Exclude: + - 'app/services/foreman_discovery/ui_notifications/failed_discovery.rb' + # Offense count: 1 +# Cop supports --auto-correct. Lint/ParenthesesAsGroupedExpression: Exclude: - 'test/unit/discovery_taxonomy_extensions_test.rb' @@ -314,6 +403,7 @@ Lint/RescueException: - 'app/controllers/api/v2/discovered_hosts_controller.rb' - 'app/controllers/concerns/foreman/controller/discovered_extensions.rb' - 'app/services/foreman_discovery/node_api/node_resource.rb' + - 'app/services/foreman_discovery/subnet_suggestion.rb' # Offense count: 7 # Cop supports --auto-correct. @@ -321,7 +411,7 @@ Lint/SendWithMixinArgument: Exclude: - 'lib/foreman_discovery/engine.rb' -# Offense count: 6 +# Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments. Lint/UnusedBlockArgument: @@ -342,6 +432,13 @@ Lint/UselessAssignment: - 'test/unit/discovery_attribute_set_test.rb' - 'test/unit/discovery_rule_test.rb' +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: AllowComments. +Lint/UselessMethodDefinition: + Exclude: + - 'app/models/host/discovered.rb' + # Offense count: 3 # Cop supports --auto-correct. Minitest/AssertEmpty: @@ -349,16 +446,24 @@ Minitest/AssertEmpty: - 'test/functional/api/v2/discovery_rules_controller_test.rb' - 'test/unit/host_discovered_test.rb' +# Offense count: 3 +# Cop supports --auto-correct. +Minitest/AssertEmptyLiteral: + Exclude: + - 'test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb' + - 'test/unit/lldp_neighbors_test.rb' + # Offense count: 2 # Cop supports --auto-correct. Minitest/AssertEqual: Exclude: - 'test/unit/discovered_extensions_test.rb' -# Offense count: 4 +# Offense count: 5 # Cop supports --auto-correct. Minitest/AssertIncludes: Exclude: + - 'test/functional/discovered_hosts_controller_test.rb' - 'test/unit/discovered_mailer_test.rb' # Offense count: 1 @@ -367,6 +472,18 @@ Minitest/AssertRespondTo: Exclude: - 'test/unit/managed_extensions_test.rb' +# Offense count: 11 +# Cop supports --auto-correct. +Minitest/LiteralAsActualArgument: + Exclude: + - 'test/unit/discovered_extensions_test.rb' + - 'test/unit/fact_to_category_resolver_test.rb' + - 'test/unit/host_discovered_test.rb' + +# Offense count: 21 +Minitest/MultipleAssertions: + Max: 18 + # Offense count: 3 # Cop supports --auto-correct. Minitest/RefuteFalse: @@ -375,6 +492,12 @@ Minitest/RefuteFalse: - 'test/functional/api/v2/discovery_rules_controller_test.rb' - 'test/unit/host_discovered_test.rb' +# Offense count: 1 +# Cop supports --auto-correct. +Minitest/RefuteNil: + Exclude: + - 'test/functional/api/v2/discovery_rules_controller_test.rb' + # Offense count: 4 Naming/AccessorMethodName: Exclude: @@ -383,7 +506,7 @@ Naming/AccessorMethodName: - 'app/services/foreman_discovery/host_converter.rb' - 'test/test_helper_discovery.rb' -# Offense count: 2 +# Offense count: 3 # Configuration parameters: EnforcedStyleForLeadingUnderscores. # SupportedStylesForLeadingUnderscores: disallowed, required, optional Naming/MemoizedInstanceVariableName: @@ -400,7 +523,7 @@ Naming/MethodName: # Offense count: 1 # Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames. -# AllowedNames: io, id, to, by, on, in, at, ip, db, os, pp +# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to Naming/MethodParameterName: Exclude: - 'app/helpers/discovered_hosts_helper.rb' @@ -413,15 +536,22 @@ Naming/MethodParameterName: # MethodDefinitionMacros: define_method, define_singleton_method Naming/PredicateName: Exclude: - - 'spec/**/*' - 'app/services/foreman_discovery/node_api/node_resource.rb' +# Offense count: 1 +# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers. +# SupportedStyles: snake_case, normalcase, non_integer +# AllowedIdentifiers: capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339 +Naming/VariableNumber: + Exclude: + - 'test/test_helper_discovery.rb' + # Offense count: 2 # Cop supports --auto-correct. Performance/RedundantMatch: Exclude: - - 'app/controllers/discovered_hosts_controller.rb' - 'app/models/host/discovered.rb' + - 'app/services/foreman_discovery/fact_to_category_resolver.rb' # Offense count: 5 # Cop supports --auto-correct. @@ -432,10 +562,11 @@ Performance/RedundantMerge: # Offense count: 2 # Cop supports --auto-correct. -Rails/ActiveRecordAliases: +# Configuration parameters: AutoCorrect. +Performance/StringInclude: Exclude: - - 'app/controllers/api/v2/discovery_rules_controller.rb' - - 'app/controllers/discovery_rules_controller.rb' + - 'test/functional/discovered_hosts_controller_test.rb' + - 'test/functional/discovery_rules_controller_test.rb' # Offense count: 2 # Cop supports --auto-correct. @@ -446,27 +577,45 @@ Rails/AssertNot: - 'test/functional/api/v2/discovered_hosts_controller_test.rb' - 'test/functional/api/v2/discovery_rules_controller_test.rb' -# Offense count: 34 +# Offense count: 29 # Cop supports --auto-correct. -# Configuration parameters: Whitelist. +# Configuration parameters: Whitelist, AllowedMethods, AllowedReceivers. # Whitelist: find_by_sql +# AllowedMethods: find_by_sql +# AllowedReceivers: Gem::Specification Rails/DynamicFindBy: Exclude: - 'app/controllers/discovered_hosts_controller.rb' - 'app/services/foreman_discovery/import_hooks/lock_templates.rb' - 'app/services/foreman_discovery/import_hooks/subnet_and_taxonomy.rb' - - 'test/functional/api/v2/settings_controller_test.rb' + - 'lib/foreman_discovery/engine.rb' - 'test/test_helper_discovery.rb' - 'test/unit/discovered_extensions_test.rb' - 'test/unit/host_discovered_test.rb' - 'test/unit/managed_extensions_test.rb' +# Offense count: 6 +# Cop supports --auto-correct. +Rails/EagerEvaluationLogMessage: + Exclude: + - 'app/controllers/concerns/foreman/controller/discovered_extensions.rb' + - 'app/mailers/discovered_mailer.rb' + - 'app/services/foreman_discovery/fact_parser.rb' + - 'app/services/foreman_discovery/host_converter.rb' + # Offense count: 1 +# Cop supports --auto-correct. +Rails/EnvironmentComparison: + Exclude: + - 'app/services/foreman_discovery/node_api/node_resource.rb' + +# Offense count: 2 # Configuration parameters: Include. # Include: app/models/**/*.rb Rails/HasManyOrHasOneDependent: Exclude: - 'app/models/concerns/discovery_taxonomy_extensions.rb' + - 'app/models/host/discovered.rb' # Offense count: 1 # Configuration parameters: Include. @@ -497,21 +646,27 @@ Rails/OutputSafety: Exclude: - 'app/helpers/discovered_hosts_helper.rb' +# Offense count: 1 +# Cop supports --auto-correct. +Rails/RedundantForeignKey: + Exclude: + - 'app/models/discovery_attribute_set.rb' + # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: strict, flexible Rails/TimeZone: Exclude: - - 'app/models/host/discovered.rb' + - 'app/services/foreman_discovery/host_fact_importer.rb' -# Offense count: 1 +# Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: Include. -# Include: app/models/**/*.rb -Rails/Validation: +# Configuration parameters: EnforcedStyle. +# SupportedStyles: exists, where +Rails/WhereExists: Exclude: - - 'app/models/discovery_rule.rb' + - 'test/functional/api/v2/discovered_hosts_controller_test.rb' # Offense count: 4 # Cop supports --auto-correct. @@ -522,9 +677,26 @@ Style/AndOr: - 'app/controllers/discovered_hosts_controller.rb' - 'app/services/foreman_discovery/node_api/node_resource.rb' -# Offense count: 15 +# Offense count: 1 +# 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: + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 1 +# Cop supports --auto-correct. +Style/CaseLikeIf: + Exclude: + - 'app/models/host/discovered.rb' + +# Offense count: 14 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. +# Configuration parameters: EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Exclude: @@ -535,13 +707,13 @@ Style/ClassAndModuleChildren: - 'app/models/host/managed_extensions.rb' - 'app/models/nic/managed_extensions.rb' - 'app/services/foreman_discovery/host_converter.rb' + - 'app/services/foreman_discovery/host_fact_importer.rb' - 'app/services/foreman_discovery/node_api/inventory.rb' - 'app/services/foreman_discovery/node_api/node_resource.rb' - 'app/services/foreman_discovery/node_api/power.rb' - 'app/services/foreman_discovery/node_api/power_service.rb' - 'test/functional/api/v2/discovered_hosts_controller_test.rb' - 'test/functional/api/v2/discovery_rules_controller_test.rb' - - 'test/functional/api/v2/settings_controller_test.rb' # Offense count: 6 # Cop supports --auto-correct. @@ -551,17 +723,11 @@ Style/ColonMethodCall: - 'app/services/foreman_discovery/fact_parser.rb' - 'test/functional/api/v2/discovered_hosts_controller_test.rb' -# Offense count: 1 -# Cop supports --auto-correct. -Style/EmptyLiteral: - Exclude: - - 'app/controllers/discovered_hosts_controller.rb' - # Offense count: 2 # Cop supports --auto-correct. -Style/ExpandPathArguments: +Style/ExplicitBlockArgument: Exclude: - - 'lib/foreman_discovery/engine.rb' + - 'test/test_helper_discovery.rb' # Offense count: 13 # Cop supports --auto-correct. @@ -574,8 +740,8 @@ Style/FormatString: - 'app/models/host/discovered.rb' - 'app/services/foreman_discovery/fact_parser.rb' -# Offense count: 36 -# Configuration parameters: EnforcedStyle. +# Offense count: 39 +# Configuration parameters: EnforcedStyle, MaxUnannotatedPlaceholdersAllowed, IgnoredMethods. # SupportedStyles: annotated, template, unannotated Style/FormatStringToken: Exclude: @@ -585,7 +751,7 @@ Style/FormatStringToken: - 'app/services/foreman_discovery/fact_parser.rb' - 'app/services/foreman_discovery/node_api/node_resource.rb' -# Offense count: 7 +# Offense count: 8 # Configuration parameters: MinBodyLength. Style/GuardClause: Exclude: @@ -594,6 +760,31 @@ Style/GuardClause: - 'app/models/discovery_rule.rb' - 'app/models/host/discovered.rb' - 'app/services/foreman_discovery/node_api/node_resource.rb' + - 'test/functional/discovered_hosts_controller_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces +Style/HashAsLastArrayItem: + Exclude: + - 'app/helpers/discovered_hosts_helper.rb' + +# Offense count: 5 +# Cop supports --auto-correct. +# Configuration parameters: AllowSplatArgument. +Style/HashConversion: + Exclude: + - 'app/controllers/discovered_hosts_controller.rb' + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 2 +# Cop supports --auto-correct. +# Configuration parameters: AllowedReceivers. +Style/HashEachMethods: + Exclude: + - 'app/services/foreman_discovery/import_hooks/discovery_attribute.rb' + - 'app/services/foreman_discovery/lldp_neighbors.rb' # Offense count: 1 # Cop supports --auto-correct. @@ -649,6 +840,19 @@ Style/Next: Style/NumericLiterals: MinDigits: 7 +# Offense count: 1 +Style/OpenStructUse: + Exclude: + - 'test/unit/fact_to_category_resolver_test.rb' + +# Offense count: 3 +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Exclude: + - 'app/services/foreman_discovery/host_converter.rb' + - 'test/test_helper_discovery.rb' + # Offense count: 9 # Cop supports --auto-correct. # Configuration parameters: PreferredDelimiters. @@ -658,9 +862,23 @@ Style/PercentLiteralDelimiters: - 'app/controllers/api/v2/discovery_rules_controller.rb' - 'test/unit/lldp_neighbors_test.rb' -# Offense count: 9 +# Offense count: 4 +# Cop supports --auto-correct. +Style/Proc: + Exclude: + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 11 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. +# SupportedStyles: same_as_string_literals, single_quotes, double_quotes +Style/QuotedSymbols: + Exclude: + - 'lib/foreman_discovery/engine.rb' + +# Offense count: 9 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle, AllowedCompactTypes. # SupportedStyles: compact, exploded Style/RaiseArgs: Exclude: @@ -690,7 +908,13 @@ Style/RedundantParentheses: Exclude: - 'app/controllers/discovery_rules_controller.rb' -# Offense count: 4 +# Offense count: 1 +# Cop supports --auto-correct. +Style/RedundantRegexpEscape: + Exclude: + - 'test/test_helper_discovery.rb' + +# Offense count: 5 # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: @@ -700,32 +924,29 @@ Style/RedundantReturn: - 'app/models/host/discovered.rb' - 'app/services/foreman_discovery/node_api/node_resource.rb' -# Offense count: 35 +# Offense count: 18 # Cop supports --auto-correct. Style/RedundantSelf: Exclude: - - 'app/models/discovery_rule.rb' - 'app/models/host/discovered.rb' - 'app/models/host/managed_extensions.rb' - 'app/models/nic/managed_extensions.rb' - 'app/services/foreman_discovery/lldp_neighbors.rb' -# Offense count: 4 +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, AllowInnerSlashes. # SupportedStyles: slashes, percent_r, mixed Style/RegexpLiteral: Exclude: - - 'test/functional/discovered_hosts_controller_test.rb' - 'test/functional/discovery_rules_controller_test.rb' - 'test/unit/managed_extensions_test.rb' -# Offense count: 5 +# Offense count: 4 # Cop supports --auto-correct. Style/RescueModifier: Exclude: - 'app/services/foreman_discovery/import_hooks/discovery_attribute.rb' - - 'lib/foreman_discovery/engine.rb' - 'test/test_helper_discovery.rb' # Offense count: 8 @@ -755,21 +976,48 @@ Style/SingleLineMethods: # Offense count: 1 # Cop supports --auto-correct. +Style/SlicingWithRange: + Exclude: + - 'app/services/foreman_discovery/lldp_neighbors.rb' + +# Offense count: 6 +# Cop supports --auto-correct. +# Configuration parameters: Mode. +Style/StringConcatenation: + Exclude: + - 'app/models/host/managed_extensions.rb' + - 'app/services/foreman_discovery/lldp_neighbors.rb' + - 'app/services/foreman_discovery/node_api/inventory.rb' + - 'app/services/foreman_discovery/node_api/power_service.rb' + - 'test/factories/discovery_host_related.rb' + - 'test/unit/discovery_rule_test.rb' + +# Offense count: 2 +# Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, MinSize. # SupportedStyles: percent, brackets Style/SymbolArray: Exclude: + - 'app/services/foreman_discovery/fact_to_category_resolver.rb' - 'test/integration/discovered_hosts_test.rb' # Offense count: 2 # Cop supports --auto-correct. -# Configuration parameters: IgnoredMethods. +# Configuration parameters: AllowMethodsWithArguments, IgnoredMethods. # IgnoredMethods: respond_to, define_method Style/SymbolProc: Exclude: - 'test/functional/api/v2/discovery_rules_controller_test.rb' -# Offense count: 2 +# Offense count: 1 +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleForMultiline. +# SupportedStylesForMultiline: comma, consistent_comma, no_comma +Style/TrailingCommaInArguments: + Exclude: + - 'app/services/foreman_discovery/ui_notifications/failed_discovery.rb' + +# Offense count: 3 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma @@ -777,8 +1025,9 @@ Style/TrailingCommaInArrayLiteral: Exclude: - 'app/controllers/discovered_hosts_controller.rb' - 'app/services/foreman_discovery/import_hook_service.rb' + - 'test/migrations/20221102075151_migrate_discovery_hostname_and_fact_column_to_array_test.rb' -# Offense count: 31 +# Offense count: 32 # Cop supports --auto-correct. # Configuration parameters: EnforcedStyleForMultiline. # SupportedStylesForMultiline: comma, consistent_comma, no_comma @@ -792,6 +1041,7 @@ Style/TrailingCommaInHashLiteral: - 'test/functional/api/v2/discovery_rules_controller_test.rb' - 'test/functional/discovered_hosts_controller_test.rb' - 'test/functional/foreman_discovery/concerns/hosts_controller_extensions_test.rb' + - 'test/test_helper_discovery.rb' - 'test/unit/fact_parser_test.rb' - 'test/unit/managed_extensions_test.rb' diff --git a/Gemfile b/Gemfile index 1c86af95..b9321765 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,4 @@ source "http://rubygems.org" gemspec +gem 'theforeman-rubocop', '~> 0.1'