about summary refs log tree commit diff
path: root/.rubocop.yml
blob: 1033db92d91fd06b8eb7f097d947e0f7a9fe8e7c (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
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'

# Reason: Some Excluded files would be candidates for refactoring but not currently addressed
# https://docs.rubocop.org/rubocop/cops_metrics.html#metricsclasslength
Metrics/ClassLength:
  CountAsOne: ['array', 'hash', 'heredoc', 'method_call']
  Exclude:
    - 'lib/mastodon/*_cli.rb'
    - 'app/controllers/admin/accounts_controller.rb'
    - 'app/controllers/api/base_controller.rb'
    - 'app/controllers/api/v1/admin/accounts_controller.rb'
    - 'app/controllers/application_controller.rb'
    - 'app/controllers/auth/registrations_controller.rb'
    - 'app/controllers/auth/sessions_controller.rb'
    - 'app/lib/activitypub/activity.rb'
    - 'app/lib/activitypub/activity/create.rb'
    - 'app/lib/activitypub/tag_manager.rb'
    - 'app/lib/feed_manager.rb'
    - 'app/lib/link_details_extractor.rb'
    - 'app/lib/request.rb'
    - 'app/lib/text_formatter.rb'
    - 'app/lib/user_settings_decorator.rb'
    - 'app/mailers/user_mailer.rb'
    - 'app/models/account.rb'
    - 'app/models/admin/account_action.rb'
    - 'app/models/form/account_batch.rb'
    - 'app/models/media_attachment.rb'
    - 'app/models/status.rb'
    - 'app/models/tag.rb'
    - 'app/models/user.rb'
    - 'app/serializers/activitypub/actor_serializer.rb'
    - 'app/serializers/activitypub/note_serializer.rb'
    - 'app/serializers/rest/status_serializer.rb'
    - 'app/services/account_search_service.rb'
    - 'app/services/activitypub/process_account_service.rb'
    - 'app/services/activitypub/process_status_update_service.rb'
    - 'app/services/backup_service.rb'
    - 'app/services/delete_account_service.rb'
    - 'app/services/fan_out_on_write_service.rb'
    - 'app/services/fetch_link_card_service.rb'
    - 'app/services/import_service.rb'
    - 'app/services/notify_service.rb'
    - 'app/services/post_status_service.rb'
    - 'app/services/update_status_service.rb'
    - 'lib/paperclip/color_extractor.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