about summary refs log tree commit diff
path: root/.rubocop.yml
blob: 99206e5977a6012d474348bb3d262655eb3c7895 (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

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

Layout/FirstHashElementIndentation:
  EnforcedStyle: consistent

Layout/LineLength:
  Max: 140 # RuboCop default 120
  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:
  Max: 34 # RuboCop default 17
  Exclude:
    - 'lib/**/*cli*.rb'
    - db/*migrate/**/*

Metrics/BlockLength:
  Max: 55 # Default 25
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'

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

Metrics/ClassLength:
  Max: 500 # Default 100
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'

Metrics/CyclomaticComplexity:
  Max: 12 # Default 7
  Exclude:
    - lib/mastodon/*cli*.rb
    - db/*migrate/**/*

Metrics/MethodLength:
  Max: 25 # RuboCop default 10
  CountAsOne: [array, heredoc]
  Exclude:
    - 'lib/mastodon/*_cli.rb'

Metrics/ModuleLength:
  Max: 200 # Default 100
  CountAsOne: [array, heredoc]

Metrics/PerceivedComplexity:
  Max: 16 # RuboCop default 8

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

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