From a92203595aaa098b10a04ab14a6a2442791d5e6f Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Fri, 23 Oct 2020 00:47:03 +0000 Subject: [PATCH] Update RuboCop to 1.0 (#32530). git-svn-id: http://svn.redmine.org/redmine/trunk@20171 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .rubocop.yml | 15 ++- .rubocop_todo.yml | 227 +++++++++++++++++++++++++++++++++++----------- Gemfile | 2 +- 3 files changed, 184 insertions(+), 60 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 67477acd5..62ddb4e1b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -4,6 +4,8 @@ AllCops: TargetRubyVersion: 2.4 TargetRailsVersion: 5.2 + NewCops: enable + Exclude: - '**/vendor/**/*' - '**/tmp/**/*' @@ -33,20 +35,20 @@ Layout/CaseIndentation: Layout/EmptyLineBetweenDefs: AllowAdjacentOneLineDefs: true +Layout/SpaceAroundEqualsInParameterDefault: + Enabled: false + Layout/SpaceBeforeBlockBraces: # "space" is used more than "no_space". # But "no_space" is more natural in one liner. # str = path.to_s.split(%r{[/\\]}).select{|p| !p.blank?}.join("/") Enabled: false -# You can see results by "rubocop --only Layout/SpaceInsideBlockBraces" Layout/SpaceInsideBlockBraces: - EnforcedStyle: no_space - SpaceBeforeBlockParameters: false + Enabled: false -# You can see results by "rubocop --only Layout/SpaceInsideHashLiteralBraces" Layout/SpaceInsideHashLiteralBraces: - EnforcedStyle: no_space + Enabled: false Lint/RaiseException: Enabled: true @@ -123,6 +125,9 @@ Style/IdenticalConditionalBranches: - 'config/initializers/10-patches.rb' - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' +Style/RaiseArgs: + Enabled: false + Style/TrailingCommaInArrayLiteral: Enabled: false diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index dccb7b428..8a7946d1b 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -1,6 +1,6 @@ # This configuration was generated by # `rubocop --auto-gen-config --exclude-limit 20 --no-offense-counts --no-auto-gen-timestamp` -# using RuboCop version 0.81.0. +# using RuboCop version 1.0.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 @@ -16,6 +16,13 @@ Layout/ArgumentAlignment: - 'test/integration/api_test/projects_test.rb' - 'test/integration/api_test/wiki_pages_test.rb' +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyleAlignWith, Severity. +# SupportedStylesAlignWith: start_of_line, begin +Layout/BeginEndAlignment: + Exclude: + - 'lib/redmine/scm/adapters/mercurial_adapter.rb' + # Cop supports --auto-correct. Layout/ClosingParenthesisIndentation: Exclude: @@ -54,6 +61,17 @@ Layout/EmptyLinesAroundAccessModifier: Exclude: - 'config/initializers/10-patches.rb' +# Cop supports --auto-correct. +# Configuration parameters: AllowAliasSyntax, AllowedMethods. +# AllowedMethods: alias_method, public, protected, private +Layout/EmptyLinesAroundAttributeAccessor: + Exclude: + - 'app/models/issue.rb' + - 'app/models/query.rb' + - 'lib/redmine/scm/adapters/abstract_adapter.rb' + - 'lib/redmine/sudo_mode.rb' + - 'test/unit/lib/redmine/safe_attributes_test.rb' + # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: empty_lines, empty_lines_except_namespace, empty_lines_special, no_empty_lines, beginning_only, ending_only @@ -214,6 +232,7 @@ Layout/MultilineOperationIndentation: Layout/RescueEnsureAlignment: Exclude: - 'db/migrate/085_add_role_tracker_old_status_index_to_workflows.rb' + - 'lib/redmine/scm/adapters/mercurial_adapter.rb' # Cop supports --auto-correct. Layout/SpaceAfterComma: @@ -240,12 +259,6 @@ Layout/SpaceAfterNot: - 'test/unit/role_test.rb' - 'test/unit/user_test.rb' -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: space, no_space -Layout/SpaceAroundEqualsInParameterDefault: - Enabled: false - # Cop supports --auto-correct. # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator. # SupportedStylesForExponentOperator: space, no_space @@ -281,20 +294,6 @@ Layout/SpaceInsideArrayLiteralBrackets: - 'test/unit/mailer_test.rb' - 'test/unit/search_test.rb' -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters. -# SupportedStyles: space, no_space -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideBlockBraces: - Enabled: false - -# Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces. -# SupportedStyles: space, no_space, compact -# SupportedStylesForEmptyBraces: space, no_space -Layout/SpaceInsideHashLiteralBraces: - Enabled: false - # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: space, no_space @@ -326,6 +325,7 @@ Layout/SpaceInsideStringInterpolation: Lint/AmbiguousBlockAssociation: Enabled: false +# Cop supports --auto-correct. Lint/AmbiguousOperator: Exclude: - 'app/controllers/application_controller.rb' @@ -333,6 +333,7 @@ Lint/AmbiguousOperator: - 'test/unit/custom_field_test.rb' - 'test/unit/member_test.rb' +# Cop supports --auto-correct. Lint/AmbiguousRegexpLiteral: Enabled: false @@ -355,24 +356,43 @@ Lint/DeprecatedClassMethods: - 'test/unit/attachment_test.rb' - 'test/unit/issue_import_test.rb' -Lint/EmptyWhen: +Lint/FloatComparison: Exclude: - - 'app/controllers/issues_controller.rb' - - 'app/controllers/wiki_controller.rb' + - 'app/models/time_entry.rb' + - 'test/system/timelog_test.rb' +# Cop supports --auto-correct. Lint/InterpolationCheck: Exclude: - 'app/models/user.rb' +# Cop supports --auto-correct. Lint/Loop: Exclude: - 'lib/redmine/helpers/gantt.rb' +Lint/MissingSuper: + Exclude: + - 'app/models/query.rb' + - 'lib/redmine/scm/adapters/bazaar_adapter.rb' + - 'lib/redmine/scm/adapters/cvs_adapter.rb' + - 'lib/redmine/scm/adapters/filesystem_adapter.rb' + - 'lib/redmine/syntax_highlighting.rb' + - 'lib/redmine/twofa/base.rb' + - 'lib/redmine/unified_diff.rb' + - 'lib/redmine/views/builders/structure.rb' + - 'lib/redmine/wiki_formatting/html_parser.rb' + +Lint/MixedRegexpCaptureTypes: + Exclude: + - 'app/helpers/application_helper.rb' + # Cop supports --auto-correct. Lint/NonDeterministicRequireOrder: Exclude: - 'lib/redmine/core_ext.rb' +# Cop supports --auto-correct. Lint/ParenthesesAsGroupedExpression: Exclude: - 'test/functional/my_controller_test.rb' @@ -416,6 +436,12 @@ Lint/UnusedBlockArgument: Lint/UnusedMethodArgument: Enabled: false +# Cop supports --auto-correct. +# Configuration parameters: ContextCreatingMethods, MethodCreatingMethods. +Lint/UselessAccessModifier: + Exclude: + - 'test/functional/repositories_git_controller_test.rb' + Lint/UselessAssignment: Enabled: false @@ -434,7 +460,7 @@ Naming/ConstantName: - 'app/models/time_entry_activity.rb' - 'lib/redmine/helpers/gantt.rb' -# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, Regex, IgnoreExecutableScripts, AllowedAcronyms. # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS Naming/FileName: Exclude: @@ -468,7 +494,7 @@ Naming/MethodName: - 'test/helpers/application_helper_test.rb' # 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: Enabled: false @@ -875,6 +901,15 @@ Security/YAMLLoad: - 'app/models/setting.rb' - 'lib/redmine/configuration.rb' +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: separated, grouped +Style/AccessorGrouping: + Exclude: + - 'app/models/user.rb' + - 'lib/redmine/helpers/gantt.rb' + - 'lib/redmine/unified_diff.rb' + # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: prefer_alias, prefer_alias_method @@ -904,7 +939,6 @@ Style/Alias: Style/AndOr: Exclude: - 'app/controllers/account_controller.rb' - - 'app/controllers/application_controller.rb' - 'app/controllers/calendars_controller.rb' - 'app/helpers/repositories_helper.rb' - 'app/models/query.rb' @@ -942,11 +976,40 @@ Style/BlockDelimiters: Enabled: false # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle. +Style/CaseLikeIf: + Exclude: + - 'app/controllers/wiki_controller.rb' + - 'app/helpers/members_helper.rb' + - 'app/models/issue_query.rb' + - 'app/models/journal.rb' + - 'app/models/repository/cvs.rb' + - 'app/models/setting.rb' + - 'app/models/time_entry.rb' + - 'app/models/user.rb' + - 'app/models/workflow_transition.rb' + - 'lib/redmine/access_control.rb' + - 'lib/redmine/export/pdf/issues_pdf_helper.rb' + - 'lib/redmine/field_format.rb' + - 'lib/redmine/i18n.rb' + - 'lib/redmine/plugin.rb' + - 'lib/redmine/scm/adapters/bazaar_adapter.rb' + - 'lib/redmine/scm/adapters/cvs_adapter.rb' + - 'lib/redmine/scm/adapters/git_adapter.rb' + - 'lib/redmine/unified_diff.rb' + +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. # SupportedStyles: nested, compact Style/ClassAndModuleChildren: Enabled: false +# Cop supports --auto-correct. +# Configuration parameters: IgnoredMethods. +# IgnoredMethods: ==, equal?, eql? +Style/ClassEqualityComparison: + Exclude: + - 'app/models/principal.rb' + # Cop supports --auto-correct. Style/ClassMethods: Exclude: @@ -987,6 +1050,11 @@ Style/ColonMethodCall: - 'test/unit/default_data_test.rb' - 'test/unit/lib/redmine/export/pdf_test.rb' +Style/CombinableLoops: + Exclude: + - 'app/models/wiki_page.rb' + - 'lib/redmine/default_data/loader.rb' + # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions. # SupportedStyles: assign_to_condition, assign_inside_condition @@ -996,11 +1064,10 @@ Style/ConditionalAssignment: Style/Documentation: Enabled: false +# Configuration parameters: EnforcedStyle. +# SupportedStyles: allowed_in_returns, forbidden Style/DoubleNegation: Exclude: - - 'app/controllers/application_controller.rb' - - 'app/helpers/application_helper.rb' - - 'app/models/attachment.rb' - 'app/models/issue_import.rb' - 'app/models/mailer.rb' - 'app/models/query.rb' @@ -1058,6 +1125,16 @@ Style/EvalWithLocation: Style/ExpandPathArguments: Enabled: false +# Cop supports --auto-correct. +Style/ExplicitBlockArgument: + Exclude: + - 'app/models/board.rb' + - 'lib/redmine/activity/fetcher.rb' + - 'lib/redmine/menu_manager.rb' + - 'lib/redmine/plugin.rb' + - 'lib/redmine/scm/adapters/subversion_adapter.rb' + - 'test/test_helper.rb' + # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle. # SupportedStyles: format, sprintf, percent @@ -1080,6 +1157,14 @@ Style/GlobalVars: Style/GuardClause: Enabled: false +# Cop supports --auto-correct. +# Configuration parameters: EnforcedStyle. +# SupportedStyles: braces, no_braces +Style/HashAsLastArrayItem: + Exclude: + - 'app/controllers/enumerations_controller.rb' + - 'app/models/board.rb' + # Cop supports --auto-correct. Style/HashEachMethods: Exclude: @@ -1115,6 +1200,7 @@ Style/IfInsideElse: Style/IfUnlessModifier: Enabled: false +# Cop supports --auto-correct. Style/IfUnlessModifierOfIfUnless: Exclude: - 'app/models/attachment.rb' @@ -1161,10 +1247,6 @@ Style/MethodCallWithoutArgsParentheses: - 'lib/redmine/scm/adapters/cvs_adapter.rb' - 'lib/redmine/scm/adapters/filesystem_adapter.rb' -Style/MethodMissingSuper: - Exclude: - - 'lib/redmine/views/builders/structure.rb' - Style/MissingRespondToMissing: Exclude: - 'lib/redmine/views/builders/structure.rb' @@ -1192,6 +1274,7 @@ Style/MultilineIfModifier: - 'lib/redmine/wiki_formatting.rb' - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' +# Cop supports --auto-correct. Style/MultilineTernaryOperator: Exclude: - 'lib/redmine/ciphering.rb' @@ -1240,6 +1323,7 @@ Style/NestedParenthesizedCalls: Exclude: - 'lib/redmine/views/labelled_form_builder.rb' +# Cop supports --auto-correct. Style/NestedTernaryOperator: Exclude: - 'app/helpers/queries_helper.rb' @@ -1271,11 +1355,16 @@ Style/NumericLiterals: MinDigits: 9 # Cop supports --auto-correct. -# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods. +# Configuration parameters: EnforcedStyle, IgnoredMethods. # SupportedStyles: predicate, comparison Style/NumericPredicate: Enabled: false +# Configuration parameters: AllowedMethods. +# AllowedMethods: respond_to_missing? +Style/OptionalBooleanParameter: + Enabled: false + # Cop supports --auto-correct. Style/OrAssignment: Exclude: @@ -1316,23 +1405,14 @@ Style/Proc: Enabled: false # Cop supports --auto-correct. -# Configuration parameters: EnforcedStyle. -# SupportedStyles: compact, exploded -Style/RaiseArgs: +Style/RedundantAssignment: Exclude: - - 'app/models/auth_source_ldap.rb' - - 'app/models/issue_query.rb' - - 'app/models/mailer.rb' + - 'app/models/mail_handler.rb' - 'app/models/query.rb' - - 'app/models/tracker.rb' - - 'app/models/user.rb' - - 'app/models/workflow_rule.rb' - - 'lib/redmine/access_control.rb' - - 'lib/redmine/default_data/loader.rb' - - 'lib/redmine/plugin.rb' - - 'lib/redmine/scm/adapters/abstract_adapter.rb' + - 'lib/redmine/scm/adapters/bazaar_adapter.rb' - 'lib/redmine/scm/adapters/filesystem_adapter.rb' - - 'lib/redmine/sort_criteria.rb' + - 'lib/redmine/wiki_formatting.rb' + - 'lib/redmine/wiki_formatting/markdown/formatter.rb' # Cop supports --auto-correct. Style/RedundantCondition: @@ -1369,19 +1449,24 @@ Style/RedundantParentheses: - 'app/controllers/search_controller.rb' - 'app/models/enumeration.rb' - 'app/models/principal.rb' - - 'app/models/query.rb' - 'app/models/repository/cvs.rb' - - 'app/models/version.rb' - 'lib/redmine/field_format.rb' - 'lib/redmine/platform.rb' - 'lib/redmine/scm/adapters/cvs_adapter.rb' - 'lib/redmine/scm/adapters/filesystem_adapter.rb' - - 'test/unit/attachment_test.rb' - - 'test/unit/lib/redmine/export/pdf_test.rb' - 'test/unit/project_test.rb' - 'test/unit/user_test.rb' - 'test/unit/version_test.rb' +# Cop supports --auto-correct. +Style/RedundantRegexpCharacterClass: + Exclude: + - 'app/helpers/application_helper.rb' + +# Cop supports --auto-correct. +Style/RedundantRegexpEscape: + Enabled: false + # Cop supports --auto-correct. # Configuration parameters: AllowMultipleReturnValues. Style/RedundantReturn: @@ -1391,6 +1476,11 @@ Style/RedundantReturn: Style/RedundantSelf: Enabled: false +# Cop supports --auto-correct. +Style/RedundantSelfAssignment: + Exclude: + - 'lib/redmine/menu_manager.rb' + # Cop supports --auto-correct. Style/RedundantSort: Exclude: @@ -1470,6 +1560,30 @@ Style/Semicolon: Style/SingleLineMethods: Enabled: false +# Configuration parameters: AllowModifier. +Style/SoleNestedConditional: + Exclude: + - 'app/controllers/application_controller.rb' + - 'app/controllers/journals_controller.rb' + - 'app/controllers/repositories_controller.rb' + - 'app/controllers/wiki_controller.rb' + - 'app/models/board.rb' + - 'app/models/changeset.rb' + - 'app/models/issue.rb' + - 'app/models/issue_import.rb' + - 'app/models/issue_relation.rb' + - 'app/models/mail_handler.rb' + - 'app/models/principal.rb' + - 'app/models/project.rb' + - 'app/models/query.rb' + - 'app/models/time_entry.rb' + - 'app/models/token.rb' + - 'app/models/user_import.rb' + - 'app/models/version.rb' + - 'app/models/watcher.rb' + - 'app/models/wiki_page.rb' + - 'lib/redmine/core_ext/active_record.rb' + # Cop supports --auto-correct. # Configuration parameters: . # SupportedStyles: use_perl_names, use_english_names @@ -1482,6 +1596,10 @@ Style/StderrPuts: - 'config/environment.rb' - 'config/initializers/10-patches.rb' +# Cop supports --auto-correct. +Style/StringConcatenation: + Enabled: false + # Cop supports --auto-correct. # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. # SupportedStyles: single_quotes, double_quotes @@ -1500,6 +1618,7 @@ Style/StringLiteralsInInterpolation: - 'lib/redmine/wiki_formatting/textile/redcloth3.rb' - 'test/unit/member_test.rb' +# Cop supports --auto-correct. Style/StructInheritance: Exclude: - 'lib/redmine/notifiable.rb' diff --git a/Gemfile b/Gemfile index 6c306eb75..735dcc745 100644 --- a/Gemfile +++ b/Gemfile @@ -92,7 +92,7 @@ group :test do gem 'capybara', '~> 3.31.0' gem "selenium-webdriver" # RuboCop - gem 'rubocop', '~> 0.81.0' + gem 'rubocop', '~> 1.0.0' gem 'rubocop-performance', '~> 1.5.0' gem 'rubocop-rails', '~> 2.5.0' end -- 2.39.5