Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

548 lines
10 KiB
YAML
Raw Permalink Normal View History

2021-02-12 10:38:03 +01:00
require:
2024-07-05 15:50:02 +02:00
- rubocop-openproject
- ./config/initializers/inflections.rb
2021-02-12 10:38:03 +01:00
plugins:
- rubocop-capybara
- rubocop-factory_bot
- rubocop-performance
- rubocop-rails
- rubocop-rspec
- rubocop-rspec_rails
# A rubocop-local.yml file can be added to customized the styles
inherit_from:
- .rubocop-local*.yml
2022-06-24 17:57:53 +02:00
inherit_mode:
merge:
# adding files to Exclude should merge with inherited instead of replacing
- Exclude
2014-11-10 17:32:10 +01:00
AllCops:
2025-01-31 12:42:09 +02:00
TargetRubyVersion: 3.4
2021-07-20 14:15:02 +02:00
# Enable any new cops in new versions by default
NewCops: enable
2014-11-10 17:32:10 +01:00
Exclude:
- "**/node_modules/**/*"
2014-11-10 17:32:10 +01:00
2025-01-24 11:13:12 +01:00
# Disable it as it is deprecated
# From https://docs.rubocop.org/rubocop-capybara/cops_capybara.html#capybaraclicklinkorbuttonstyle
# "This cop is deprecated. We plan to remove this in the next major version update to 3.0."
Capybara/ClickLinkOrButtonStyle:
Enabled: false
FactoryBot/ConsistentParenthesesStyle:
Enabled: false
2023-06-09 11:00:15 +02:00
FactoryBot/SyntaxMethods:
Enabled: true
Gemspec/RequiredRubyVersion:
Exclude:
- modules/**/*.gemspec
2020-03-04 16:27:57 +01:00
Layout/ConditionPosition:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Layout/DotPosition:
EnforcedStyle: leading
2020-03-04 16:27:57 +01:00
Layout/LineLength:
Max: 130
Layout/MultilineMethodCallIndentation:
2014-11-10 17:32:10 +01:00
Enabled: false
2021-11-01 09:09:35 +01:00
# Rubymine doesn't support the same indentation style
# and will auto-format against it with our editorconfig
Layout/MultilineOperationIndentation:
Enabled: false
2020-03-04 16:27:57 +01:00
2025-12-02 15:27:08 +02:00
Lint/AmbiguousBlockAssociation:
2026-04-27 09:37:32 +02:00
AllowedMethods:
- change
2025-12-02 15:27:08 +02:00
2020-03-04 16:27:57 +01:00
Lint/AmbiguousOperator:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/AmbiguousRegexpLiteral:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/AssignmentInCondition:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/DeprecatedClassMethods:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/ElseLayout:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/FlipFlop:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/LiteralInInterpolation:
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/Loop:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/ParenthesesAsGroupedExpression:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/RequireParentheses:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/SuppressedException:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/UnderscorePrefixedVariableName:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Lint/Void:
2014-11-10 17:32:10 +01:00
Enabled: false
2025-12-02 15:27:08 +02:00
Metrics/AbcSize:
Enabled: true
Exclude:
- "spec/**/*.rb"
- "modules/*/spec/**/*.rb"
2022-04-19 17:52:51 +02:00
2025-12-02 15:27:08 +02:00
Metrics/BlockLength:
2014-11-10 17:32:10 +01:00
Enabled: false
2025-12-02 15:27:08 +02:00
Metrics/BlockNesting:
2014-11-10 17:32:10 +01:00
Enabled: false
2025-12-02 15:27:08 +02:00
Metrics/ClassLength:
2014-11-10 17:32:10 +01:00
Enabled: false
2025-12-02 15:27:08 +02:00
Metrics/CyclomaticComplexity:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Metrics/MethodLength:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Metrics/ModuleLength:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Metrics/ParameterLists:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Naming/AccessorMethodName:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Naming/AsciiIdentifiers:
2014-11-10 17:32:10 +01:00
Enabled: false
2021-09-10 15:02:08 +02:00
Naming/ClassAndModuleCamelCase:
AllowedNames:
- V2_1
2020-03-04 16:27:57 +01:00
Naming/FileName:
2014-11-10 17:32:10 +01:00
Enabled: false
2026-05-12 21:48:46 +02:00
Naming/MethodParameterName:
AllowedNames:
- id
- cf # custom fields are commonly abbreviated like that
Naming/PredicatePrefix:
2020-03-04 16:27:57 +01:00
ForbiddenPrefixes:
- is_
2014-11-10 17:32:10 +01:00
Naming/VariableNumber:
AllowedPatterns:
2026-04-27 09:20:11 +02:00
- "\\w_20\\d\\d" # allow dates like christmas_2022 or date_2034_04_12
- "\\w\\d++(_\\d++)+" # allow hierarchical data like child1_2_5 (second + in regex is possessive qualifier)
- "custom_field_\\d+" # allow custom field method names to be called with send :custom_field_1001
2025-12-02 15:27:08 +02:00
OpenProject/AddPreviewForViewComponent:
Include:
- app/components/op_turbo/**.rb
- app/components/op_primer/**.rb
- app/components/open_project/**.rb
- app/components/concerns/**.rb
Performance/Casecmp:
2021-05-03 10:14:48 +02:00
Enabled: false
2021-06-24 14:03:29 +02:00
# Don't force us to use tag instead of content_tag
# as this breaks angular elements
2021-07-14 12:06:15 +02:00
Rails/ContentTag:
Enabled: false
2021-05-03 10:14:48 +02:00
2025-12-02 15:27:08 +02:00
# dynamic finders cop clashes with capybara ID cop
Rails/DynamicFindBy:
Enabled: true
AllowedMethods:
- find_by_display_id
- find_by_display_id!
- find_by_semantic_identifier
2025-12-02 15:27:08 +02:00
Exclude:
- "spec/features/**/*.rb"
- "spec/support/**/*.rb"
- "modules/*/spec/features/**/*.rb"
Whitelist:
- find_by_login
- find_by_mail
- find_by_plaintext_value
2026-04-27 09:20:11 +02:00
- find_by_rss_key
- find_by_unique
2026-04-27 09:22:18 +02:00
- find_by_unique!
2026-04-27 09:20:11 +02:00
- find_by_api_key
2025-12-02 15:27:08 +02:00
# Allow reorder to prevent find each cop triggering
Rails/FindEach:
AllowedMethods:
- order
- reorder
- limit
- select
- lock
Exclude:
- "spec/**/*"
- "modules/**/spec/**/*"
2025-12-02 15:27:08 +02:00
# The http verbs in Rack::Test do not accept named parameters (params: params)
Rails/HttpPositionalArguments:
Enabled: false
# Disable I18n.locale = in specs, where it is reset
# by us explicitly
Rails/I18nLocaleAssignment:
Enabled: true
Exclude:
- "spec/**/*.rb"
- "modules/*/spec/**/*.rb"
2026-02-06 15:58:47 +01:00
Rails/I18nLocaleTexts:
Enabled: true
Exclude:
- "spec/**/*.rb"
- "modules/*/spec/**/*.rb"
2026-02-06 15:58:47 +01:00
2025-12-02 15:27:08 +02:00
# We have config.active_record.belongs_to_required_by_default = false ,
# which means, we do have to declare presence validators on belongs_to relations.
Rails/RedundantPresenceValidationOnBelongsTo:
Enabled: false
2022-02-02 17:39:47 +01:00
# require_dependency is an obsolete method for Rails applications running in Zeitwerk mode.
Rails/RequireDependency:
Enabled: true
2025-12-02 15:27:08 +02:00
# Require save! to prevent saving without validation when saving outside of a condition.
2025-12-02 14:17:55 +01:00
Rails/SaveBang:
Enabled: true
Exclude:
- "spec/**/*"
- "modules/**/spec/**/*"
2025-12-02 14:17:55 +01:00
2025-12-02 15:27:08 +02:00
# There are valid cases in which to use methods like:
# * update_all
# * touch_all
Rails/SkipsModelValidations:
Enabled: false
# Allow number HTTP status codes in specs
RSpecRails/HttpStatus:
Enabled: false
2026-03-10 15:52:49 -03:00
# The block form of `travel_to` is often the tighter and safer option in our Rails specs.
RSpecRails/TravelAround:
Enabled: false
2025-12-02 15:27:08 +02:00
# expect not_to change is not working as expected
# if you chain it with multiple expected changes
RSpec/ChangeByZero:
Enabled: false
RSpec/ContextWording:
Prefixes:
- and
- as
- even
- for
- given
- having
- if
- in
- "on"
- to
- unless
- via
- when
- with
- within
- without
RSpec/DescribeClass:
Enabled: true
Exclude:
- "spec/features/**/*.rb"
- "modules/*/spec/features/**/*.rb"
# Don't force the second argument of describe
# to be .class_method or #instance_method
RSpec/DescribeMethod:
Enabled: false
2021-05-03 09:11:07 +02:00
# For feature specs, we tend to have longer specs that cover a larger part of the functionality.
# This is done for multiple reasons:
# * performance, as setting up integration tests is costly
# * following a scenario that is closer to how a user interacts
RSpec/ExampleLength:
2021-05-03 10:14:48 +02:00
Max: 25
2021-05-03 09:11:07 +02:00
Enabled: true
Exclude:
- "spec/features/**/*.rb"
- "modules/*/spec/features/**/*.rb"
2021-05-03 09:11:07 +02:00
2025-12-02 15:27:08 +02:00
# Prevent "fit" or similar to be committed
RSpec/Focus:
Enabled: true
2025-05-27 17:39:06 +02:00
# Nothing wrong with `include_examples` when used properly.
RSpec/IncludeExamples:
Enabled: false
2025-12-02 15:27:08 +02:00
# Do not bother if `let` statements use an index in their name
RSpec/IndexedLet:
2024-05-22 12:21:28 +02:00
Enabled: false
2025-12-02 15:27:08 +02:00
RSpec/LeadingSubject:
Enabled: false
2022-09-21 14:47:40 +02:00
2025-12-02 15:27:08 +02:00
# We use let!() to ensure dependencies are created
# instead of let() and referencing them explicitly
RSpec/LetSetup:
Enabled: false
2024-08-19 08:23:12 +02:00
2025-12-02 15:27:08 +02:00
# We have specs that have no expect(..) syntax,
# but only helper classes that expect themselves
RSpec/NoExpectationExample:
Enabled: false
2021-05-03 09:11:07 +02:00
# See RSpec/ExampleLength for why feature specs are excluded
2021-05-03 10:14:48 +02:00
RSpec/MultipleExpectations:
Max: 15
2021-05-03 09:11:07 +02:00
Enabled: true
Exclude:
- "spec/features/**/*.rb"
- "modules/*/spec/features/**/*.rb"
2021-05-03 09:11:07 +02:00
2021-05-03 10:14:48 +02:00
RSpec/MultipleMemoizedHelpers:
Enabled: false
2021-04-20 13:45:42 +02:00
2021-07-20 16:31:14 +02:00
RSpec/NestedGroups:
Enabled: false
2021-04-20 13:45:42 +02:00
# Don't force the second argument of describe
# to match the exact file name
2023-09-11 09:03:13 +02:00
RSpec/SpecFilePathFormat:
CustomTransform:
2024-10-15 10:56:10 +02:00
OpenIDConnect: openid_connect
OAuthClients: oauth_clients
XWiki: xwiki
XWikiProviders: xwiki_providers
2025-12-02 10:30:05 +01:00
EnforcedInflector: active_support
2023-09-11 09:03:13 +02:00
IgnoreMethods: true
2021-07-26 12:06:07 +02:00
RSpec/NamedSubject:
Enabled: false
2020-03-04 16:27:57 +01:00
Style/Alias:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/AndOr:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/ArrayJoin:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/AsciiComments:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/Attr:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/CaseEquality:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/CharacterLiteral:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/ClassAndModuleChildren:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/ClassVars:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/CollectionMethods:
PreferredMethods:
find: detect
reduce: inject
collect: map
find_all: select
2014-11-10 17:32:10 +01:00
2020-03-04 16:27:57 +01:00
Style/ColonMethodCall:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/CommentAnnotation:
2017-03-30 13:03:51 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/Documentation:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/DoubleNegation:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/EachWithObject:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/EmptyLiteral:
2014-11-10 17:32:10 +01:00
Enabled: false
Style/EndlessMethod:
Enabled: true
2020-03-04 16:27:57 +01:00
Style/EvenOdd:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/FormatString:
2014-11-10 17:32:10 +01:00
Enabled: false
Style/FormatStringToken:
2026-04-27 09:37:32 +02:00
AllowedMethods:
- redirect
2025-12-02 15:27:08 +02:00
Style/FrozenStringLiteralComment:
Enabled: true
EnforcedStyle: always_true
Style/HashEachMethods:
Enabled: true
Style/HashTransformKeys:
Enabled: true
Style/HashTransformValues:
Enabled: true
2020-03-04 16:27:57 +01:00
Style/GlobalVars:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/GuardClause:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/IfUnlessModifier:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/IfWithSemicolon:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/InlineComment:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/Lambda:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/LambdaCall:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/LineEndConcatenation:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/ModuleFunction:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/NegatedIf:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/NegatedWhile:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/Next:
2016-07-29 09:34:15 +01:00
Enabled: false
2014-11-10 17:32:10 +01:00
2020-03-04 16:27:57 +01:00
Style/NilComparison:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/Not:
2014-11-10 17:32:10 +01:00
Enabled: false
2025-12-02 15:27:08 +02:00
Style/NumericLiterals:
Enabled: false
# Avoid enforcing "positive?"
Style/NumericPredicate:
Enabled: false
2020-03-04 16:27:57 +01:00
Style/OneLineConditional:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/PercentLiteralDelimiters:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/PerlBackrefs:
2014-11-10 17:32:10 +01:00
Enabled: false
Style/PreferredHashMethods:
Enabled: false
2020-03-04 16:27:57 +01:00
Style/Proc:
Enabled: false
2020-03-04 16:27:57 +01:00
Style/RaiseArgs:
Enabled: false
Style/RescueModifier:
Exclude:
- "spec/**/*"
- "modules/**/spec/**/*"
2020-03-04 16:27:57 +01:00
Style/RegexpLiteral:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/SelfAssignment:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/SingleLineBlockParams:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/SingleLineMethods:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/SignalException:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/SpecialGlobalVars:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
# Forcing single quotes doesn't give any reasonable advantages. To the contrary:
# it forces you to change the quotes every time you want to add interpolation,
# newlines or other escape sequences (\n), or quotes (') to a string. Rubbish.
# Don't even think about performance. That never was a valid argument to begin with.
#
# For the record: using single quotes does NOT have any performance advantages.
# Even if it did, this would be a silly argument.
#
2024-03-07 16:20:35 +01:00
# Quote away.
2020-03-04 16:27:57 +01:00
Style/StringLiterals:
2024-03-07 16:20:35 +01:00
EnforcedStyle: double_quotes
2014-11-10 17:32:10 +01:00
2020-03-04 16:27:57 +01:00
Style/TrivialAccessors:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/VariableInterpolation:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/WhenThen:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/WhileUntilModifier:
2014-11-10 17:32:10 +01:00
Enabled: false
2020-03-04 16:27:57 +01:00
Style/WordArray:
2014-11-10 17:32:10 +01:00
Enabled: false