about summary refs log tree commit diff
path: root/.rubocop.yml
blob: 9e9240636ffceb2961454f875fd60c3caf54ce3f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
inherit_from: .rubocop_todo.yml

inherit_mode:
  merge:
    - Exclude

require:
  - rubocop-rails
  - rubocop-rspec
  - rubocop-performance
  - rubocop-capybara

AllCops:
  TargetRubyVersion: 2.7
  DisplayCopNames: true
  DisplayStyleGuide: true
  ExtraDetails: true
  UseCache: true
  CacheRootDirectory: tmp
  NewCops: enable
  Exclude:
    - db/schema.rb
    - 'bin/*'
    - 'Rakefile'
    - 'node_modules/**/*'
    - 'Vagrantfile'
    - 'vendor/**/*'
    - 'lib/json_ld/*'
    - 'lib/templates/**/*'

Layout/FirstHashElementIndentation:
  EnforcedStyle: consistent

Layout/LineLength:
  AllowedPatterns:
    # Allow comments to be long lines
    - !ruby/regexp / \# .*$/
    - !ruby/regexp /^\# .*$/
  Exclude:
    - lib/**/*cli*.rb
    - db/*migrate/**/*
    - db/seeds/**/*

Lint/UselessAccessModifier:
  ContextCreatingMethods:
    - class_methods

Metrics/AbcSize:
  Exclude:
    - 'lib/**/*cli*.rb'
    - db/*migrate/**/*

Metrics/BlockLength:
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'

Metrics/BlockNesting:
  Exclude:
    - 'lib/mastodon/*_cli.rb'

Metrics/ClassLength:
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'

Metrics/CyclomaticComplexity:
  Exclude:
    - lib/mastodon/*cli*.rb
    - db/*migrate/**/*

Metrics/MethodLength:
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'

Metrics/ModuleLength:
  CountAsOne: [array, heredoc]

Rails/HttpStatus:
  EnforcedStyle: numeric

Rails/Exit:
  Exclude:
    - 'lib/mastodon/*_cli.rb'
    - 'lib/mastodon/cli_helper.rb'
    - 'lib/cli.rb'

# Reason: Some single letter camel case files shouldn't be split
# https://docs.rubocop.org/rubocop-rspec/cops_rspec.html#rspecfilepath
RSpec/FilePath:
  CustomTransform:
    ActivityPub: activitypub # Ignore the snake_case due to the amount of files to rename
    DeepL: deepl
    FetchOEmbedService: fetch_oembed_service
    JsonLdHelper: jsonld_helper
    OEmbedController: oembed_controller
    OStatus: ostatus
    NodeInfoController: nodeinfo_controller # NodeInfo isn't snake_cased for any of the instances
  Exclude:
    - 'spec/config/initializers/rack_attack_spec.rb' # namespaces usually have separate folder
    - 'spec/lib/sanitize_config_spec.rb' # namespaces usually have separate folder
    - 'spec/controllers/concerns/account_controller_concern_spec.rb' # Concerns describe ApplicationController and don't fit naming
    - 'spec/controllers/concerns/export_controller_concern_spec.rb'
    - 'spec/controllers/concerns/localized_spec.rb'
    - 'spec/controllers/concerns/rate_limit_headers_spec.rb'
    - 'spec/controllers/concerns/signature_verification_spec.rb'
    - 'spec/controllers/concerns/user_tracking_concern_spec.rb'

RSpec/NotToNot:
  EnforcedStyle: to_not

RSpec/Rails/HttpStatus:
  EnforcedStyle: numeric

# Reason:
# https://docs.rubocop.org/rubocop/cops_style.html#styleclassandmodulechildren
Style/ClassAndModuleChildren:
  Enabled: false

# Reason: Classes mostly self-document with their names
# https://docs.rubocop.org/rubocop/cops_style.html#styledocumentation
Style/Documentation:
  Enabled: false

Style/HashSyntax:
  EnforcedStyle: ruby19_no_mixed_keys

Style/NumericLiterals:
  AllowedPatterns:
    - \d{4}_\d{2}_\d{2}_\d{6} # For DB migration date version number readability

Style/PercentLiteralDelimiters:
  PreferredDelimiters:
    '%i': '()'
    '%w': '()'

Style/RescueStandardError:
  EnforcedStyle: implicit

Style/TrailingCommaInArrayLiteral:
  EnforcedStyleForMultiline: 'comma'

Style/TrailingCommaInHashLiteral:
  EnforcedStyleForMultiline: 'comma'

Style/SymbolArray:
  Enabled: false