rubocop-discourse-base 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80ac6ab7fbd6cdf67d3de760135b8501095034277eb4f0ea5d18ab0e7c60d5f9
4
+ data.tar.gz: f442cf305522aaabc3d89a4702e8848ac265143d5c603b0c89a1616ebe74100e
5
+ SHA512:
6
+ metadata.gz: a32262270343ba9dc0af2bdcf1bf253ce68d53c1817a723764f1b27622ceb096fbab57a3ad9872dd9724e629c33aaca5cec061affcac8a1941b917f2310e7d7b
7
+ data.tar.gz: 25b7c5515e48a21d6185314f1df05be80d3c2fe4ce43e0dd8f812121ccfff6ea363cf0cb006e9b9c8eca6c39eef46cbbec0e81b6b74f8b0049ae73da2da9b250
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Civilized Discourse Construction Kit, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # rubocop-discourse-base
2
+
3
+ Shared RuboCop configuration used across Discourse projects. It ships the common core cops we enable, layout preferences, and an optional rspec profile.
4
+
5
+ ## Installation
6
+
7
+ Add the gem to your development group:
8
+
9
+ ```ruby
10
+ group :development, :test do
11
+ gem "rubocop-discourse-base"
12
+ end
13
+ ```
14
+
15
+ ## Configuration
16
+
17
+ Base config (core + layout) for non-Syntax Tree users:
18
+
19
+ ```yml
20
+ inherit_gem:
21
+ rubocop-discourse-base: default.yml
22
+ ```
23
+
24
+ `default.yml` is kept for backwards compatibility and includes our layout cops. It inherits `stree-compat.yml` (core cops only) plus `rubocop-layout.yml`.
25
+
26
+ Syntax Tree–friendly config (omits Layout cops so it can be used with the formatter):
27
+
28
+ ```yml
29
+ inherit_gem:
30
+ rubocop-discourse-base: stree-compat.yml
31
+ ```
32
+
33
+ Minimal core-only config (same cops as `stree-compat.yml`):
34
+
35
+ ```yml
36
+ inherit_gem:
37
+ rubocop-discourse-base: rubocop-core.yml
38
+ ```
39
+
40
+ RSpec support (requires `gem "rubocop-rspec"`); use with either `default.yml` or `stree-compat.yml`:
41
+
42
+ ```yml
43
+ inherit_gem:
44
+ rubocop-discourse-base:
45
+ - default.yml # or stree-compat.yml
46
+ - rubocop-rspec.yml
47
+ ```
48
+
49
+ Then run `bundle exec rubocop` as usual.
data/default.yml ADDED
@@ -0,0 +1,3 @@
1
+ inherit_from:
2
+ - ./stree-compat.yml
3
+ - ./rubocop-layout.yml
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RuboCop
4
+ module Discourse
5
+ module Base
6
+ VERSION = "1.0.0"
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "base/version"
4
+
5
+ module RuboCop
6
+ module Discourse
7
+ module Base
8
+ end
9
+ end
10
+ end
data/rubocop-core.yml ADDED
@@ -0,0 +1,143 @@
1
+ Security:
2
+ Enabled: true
3
+
4
+ Security/IoMethods:
5
+ Enabled: true
6
+
7
+ Security/CompoundHash:
8
+ Enabled: true
9
+
10
+ # Prefer &&/|| over and/or.
11
+ Style/AndOr:
12
+ Enabled: true
13
+
14
+ Style/FrozenStringLiteralComment:
15
+ Enabled: true
16
+
17
+ # Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
18
+ Style/HashSyntax:
19
+ Enabled: true
20
+ EnforcedShorthandSyntax: either
21
+
22
+ # Defining a method with parameters needs parentheses.
23
+ Style/MethodDefParentheses:
24
+ Enabled: true
25
+
26
+ Style/SingleLineMethods:
27
+ Enabled: true
28
+
29
+ Style/Semicolon:
30
+ Enabled: true
31
+ AllowAsExpressionSeparator: true
32
+
33
+ Style/RedundantReturn:
34
+ Enabled: true
35
+
36
+ Style/GlobalVars:
37
+ Enabled: true
38
+ Severity: warning
39
+ Exclude:
40
+ - "lib/tasks/**/*"
41
+ - "script/**/*"
42
+ - "**/spec/**/*"
43
+
44
+ Style/InvertibleUnlessCondition:
45
+ Enabled: true
46
+
47
+ Style/NegatedUnless:
48
+ Enabled: true
49
+
50
+ Style/UnlessElse:
51
+ Enabled: true
52
+
53
+ Style/UnlessLogicalOperators:
54
+ Enabled: true
55
+
56
+ Lint/Debugger:
57
+ Enabled: true
58
+
59
+ # Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
60
+ Lint/RequireParentheses:
61
+ Enabled: true
62
+
63
+ Lint/ShadowingOuterLocalVariable:
64
+ Enabled: true
65
+
66
+ Bundler/OrderedGems:
67
+ Enabled: false
68
+
69
+ Layout/LineLength:
70
+ Enabled: false
71
+
72
+ Lint/ParenthesesAsGroupedExpression:
73
+ Enabled: true
74
+
75
+ Lint/DuplicateMethods:
76
+ Enabled: true
77
+
78
+ Lint/RedundantWithIndex:
79
+ Enabled: true
80
+
81
+ Lint/RedundantRequireStatement:
82
+ Enabled: true
83
+
84
+ Lint/LiteralInInterpolation:
85
+ Enabled: true
86
+
87
+ Lint/RedundantStringCoercion:
88
+ Enabled: true
89
+
90
+ Lint/BooleanSymbol:
91
+ Enabled: true
92
+ AutoCorrect: false # it breaks the code
93
+
94
+ Lint/ShadowedArgument:
95
+ Enabled: true
96
+
97
+ Lint/RedundantCopDisableDirective:
98
+ Enabled: true
99
+
100
+ Lint/EmptyEnsure:
101
+ Enabled: true
102
+
103
+ Lint/RedundantWithObject:
104
+ Enabled: true
105
+
106
+ Lint/SelfAssignment:
107
+ Enabled: true
108
+
109
+ Lint/Void:
110
+ Enabled: true
111
+
112
+ Lint/UselessMethodDefinition:
113
+ Enabled: true
114
+
115
+ Lint/UnreachableCode:
116
+ Enabled: true
117
+
118
+ Lint/DeprecatedOpenSSLConstant:
119
+ Enabled: true
120
+
121
+ Lint/DisjunctiveAssignmentInConstructor:
122
+ Enabled: true
123
+
124
+ Lint/NonLocalExitFromIterator:
125
+ Enabled: true
126
+
127
+ Lint/DeprecatedClassMethods:
128
+ Enabled: true
129
+
130
+ Lint/SafeNavigationChain:
131
+ Enabled: true
132
+
133
+ Lint/RedundantSafeNavigation:
134
+ Enabled: true
135
+
136
+ Lint/EmptyConditionalBody:
137
+ Enabled: true
138
+
139
+ Lint/SafeNavigationConsistency:
140
+ Enabled: true
141
+
142
+ Lint/OrAssignmentToConstant:
143
+ Enabled: true
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rubocop/discourse/base/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rubocop-discourse-base"
7
+ spec.version = RuboCop::Discourse::Base::VERSION
8
+ spec.summary = "Common RuboCop configurations used by Discourse"
9
+ spec.authors = ["Discourse Team"]
10
+ spec.license = "MIT"
11
+ spec.homepage = "https://github.com/discourse/rubocop-discourse-base"
12
+
13
+ config_files = %w[
14
+ default.yml
15
+ rubocop-core.yml
16
+ rubocop-layout.yml
17
+ rubocop-rspec.yml
18
+ stree-compat.yml
19
+ ]
20
+
21
+ spec.files =
22
+ %w[LICENSE README.md rubocop-discourse-base.gemspec] + config_files + Dir["lib/**/*.rb"]
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.required_ruby_version = ">= 3.0"
26
+ spec.add_runtime_dependency "rubocop", ">= 1.80.0"
27
+
28
+ spec.add_development_dependency "rake", "~> 13.1.0"
29
+ end
@@ -0,0 +1,80 @@
1
+ # Align `when` with `case`.
2
+ Layout/CaseIndentation:
3
+ Enabled: true
4
+
5
+ # Align comments with method definitions.
6
+ Layout/CommentIndentation:
7
+ Enabled: true
8
+
9
+ # No extra empty lines.
10
+ Layout/EmptyLines:
11
+ Enabled: true
12
+
13
+ # Use empty lines between definitions.
14
+ Layout/EmptyLineBetweenDefs:
15
+ Enabled: true
16
+
17
+ # Two spaces, no tabs (for indentation).
18
+ Layout/IndentationWidth:
19
+ Enabled: true
20
+
21
+ Layout/SpaceAfterColon:
22
+ Enabled: true
23
+
24
+ Layout/SpaceAfterComma:
25
+ Enabled: true
26
+
27
+ Layout/SpaceAroundEqualsInParameterDefault:
28
+ Enabled: true
29
+
30
+ Layout/SpaceAroundKeyword:
31
+ Enabled: true
32
+
33
+ Layout/SpaceAroundOperators:
34
+ Enabled: true
35
+
36
+ Layout/SpaceBeforeFirstArg:
37
+ Enabled: true
38
+
39
+ # Use `foo {}` not `foo{}`.
40
+ Layout/SpaceBeforeBlockBraces:
41
+ Enabled: true
42
+
43
+ # Use `foo { bar }` not `foo {bar}`.
44
+ Layout/SpaceInsideBlockBraces:
45
+ Enabled: true
46
+
47
+ # Use `{ a: 1 }` not `{a:1}`.
48
+ Layout/SpaceInsideHashLiteralBraces:
49
+ Enabled: true
50
+
51
+ Layout/SpaceInsideParens:
52
+ Enabled: true
53
+
54
+ # Detect hard tabs, no hard tabs.
55
+ Layout/IndentationStyle:
56
+ Enabled: true
57
+
58
+ # Blank lines should not have any spaces.
59
+ Layout/TrailingEmptyLines:
60
+ Enabled: true
61
+
62
+ # No trailing whitespace.
63
+ Layout/TrailingWhitespace:
64
+ Enabled: true
65
+
66
+ Layout/BlockAlignment:
67
+ Enabled: true
68
+
69
+ # Align `end` with the matching keyword or starting expression except for
70
+ # assignments, where it should be aligned with the LHS.
71
+ Layout/EndAlignment:
72
+ Enabled: true
73
+ EnforcedStyleAlignWith: variable
74
+
75
+ Layout/MultilineMethodCallIndentation:
76
+ Enabled: true
77
+ EnforcedStyle: indented
78
+
79
+ Layout/HashAlignment:
80
+ Enabled: true
data/rubocop-rspec.yml ADDED
@@ -0,0 +1,220 @@
1
+ plugins:
2
+ - rubocop-rspec
3
+
4
+ RSpec/AnyInstance:
5
+ Enabled: false # To be decided
6
+
7
+ RSpec/AroundBlock:
8
+ Enabled: true
9
+
10
+ RSpec/BeforeAfterAll:
11
+ Enabled: true
12
+
13
+ RSpec/ChangeByZero:
14
+ Enabled: true
15
+
16
+ RSpec/ContextMethod:
17
+ Enabled: true
18
+
19
+ RSpec/ContextWording:
20
+ Enabled: true
21
+ Prefixes:
22
+ - when
23
+ - with
24
+ - without
25
+ - for
26
+ - while
27
+ - if
28
+ - as
29
+ - after
30
+ - in
31
+
32
+ RSpec/DescribeClass:
33
+ Enabled: true
34
+
35
+ RSpec/DescribeMethod:
36
+ Enabled: true
37
+
38
+ RSpec/DescribeSymbol:
39
+ Enabled: false # To be decided
40
+
41
+ RSpec/DescribedClass:
42
+ Enabled: false # To be decided
43
+
44
+ RSpec/DescribedClassModuleWrapping:
45
+ Enabled: true
46
+
47
+ RSpec/EmptyExampleGroup:
48
+ Enabled: true
49
+
50
+ RSpec/EmptyLineAfterExample:
51
+ Enabled: false # TODO
52
+
53
+ RSpec/EmptyLineAfterExampleGroup:
54
+ Enabled: false # TODO
55
+
56
+ RSpec/EmptyLineAfterFinalLet:
57
+ Enabled: false # TODO
58
+
59
+ RSpec/EmptyLineAfterHook:
60
+ Enabled: false # TODO
61
+
62
+ RSpec/EmptyLineAfterSubject:
63
+ Enabled: true
64
+
65
+ RSpec/ExampleLength:
66
+ Enabled: false # To be decided
67
+
68
+ RSpec/ExampleWithoutDescription:
69
+ Enabled: true
70
+
71
+ RSpec/ExampleWording:
72
+ Enabled: false # TODO
73
+
74
+ RSpec/ExpectActual:
75
+ Enabled: true
76
+
77
+ RSpec/ExpectChange:
78
+ Enabled: false # To be decided
79
+
80
+ RSpec/ExpectInHook:
81
+ Enabled: false
82
+
83
+ RSpec/ExpectOutput:
84
+ Enabled: true
85
+
86
+ RSpec/SpecFilePathFormat:
87
+ Enabled: false # To be decided
88
+
89
+ RSpec/SpecFilePathSuffix:
90
+ Enabled: true
91
+
92
+ RSpec/Focus:
93
+ Enabled: true
94
+
95
+ RSpec/HookArgument:
96
+ Enabled: false # TODO
97
+
98
+ RSpec/HooksBeforeExamples:
99
+ Enabled: false # TODO
100
+
101
+ RSpec/ImplicitBlockExpectation:
102
+ Enabled: true
103
+
104
+ RSpec/ImplicitExpect:
105
+ Enabled: false # To be decided
106
+
107
+ RSpec/ImplicitSubject:
108
+ Enabled: false # To be decided
109
+
110
+ RSpec/InstanceSpy:
111
+ Enabled: true
112
+
113
+ RSpec/InstanceVariable:
114
+ Enabled: false # TODO
115
+
116
+ RSpec/ItBehavesLike:
117
+ Enabled: true
118
+
119
+ RSpec/IteratedExpectation:
120
+ Enabled: false # To be decided
121
+
122
+ RSpec/LeadingSubject:
123
+ Enabled: true
124
+
125
+ RSpec/LeakyConstantDeclaration:
126
+ Enabled: false # To be decided
127
+
128
+ RSpec/LetBeforeExamples:
129
+ Enabled: false # TODO
130
+
131
+ RSpec/LetSetup:
132
+ Enabled: false # TODO
133
+
134
+ RSpec/MessageChain:
135
+ Enabled: true
136
+
137
+ RSpec/MessageSpies:
138
+ Enabled: true
139
+
140
+ RSpec/MissingExampleGroupArgument:
141
+ Enabled: true
142
+
143
+ RSpec/MultipleExpectations:
144
+ Enabled: false
145
+
146
+ RSpec/MultipleDescribes:
147
+ Enabled: false # TODO
148
+
149
+ RSpec/MultipleMemoizedHelpers:
150
+ Enabled: false
151
+
152
+ RSpec/MultipleSubjects:
153
+ Enabled: true
154
+
155
+ RSpec/NamedSubject:
156
+ Enabled: true
157
+
158
+ RSpec/NestedGroups:
159
+ Enabled: false # To be decided
160
+
161
+ RSpec/OverwritingSetup:
162
+ Enabled: true
163
+
164
+ RSpec/ReceiveCounts:
165
+ Enabled: true
166
+
167
+ RSpec/ReceiveNever:
168
+ Enabled: true
169
+
170
+ RSpec/RepeatedDescription:
171
+ Enabled: false
172
+
173
+ RSpec/RepeatedExample:
174
+ Enabled: false # TODO
175
+
176
+ RSpec/RepeatedExampleGroupBody:
177
+ Enabled: false # TODO
178
+
179
+ RSpec/RepeatedExampleGroupDescription:
180
+ Enabled: false
181
+
182
+ RSpec/ReturnFromStub:
183
+ Enabled: true
184
+
185
+ RSpec/ScatteredSetup:
186
+ Enabled: false # TODO
187
+
188
+ RSpec/SharedContext:
189
+ Enabled: true
190
+
191
+ RSpec/SharedExamples:
192
+ Enabled: true
193
+
194
+ RSpec/SingleArgumentMessageChain:
195
+ Enabled: true
196
+
197
+ RSpec/SubjectStub:
198
+ Enabled: true
199
+
200
+ RSpec/UnspecifiedException:
201
+ Enabled: true
202
+
203
+ RSpec/VerifiedDoubles:
204
+ Enabled: true
205
+
206
+ RSpec/VoidExpect:
207
+ Enabled: true
208
+
209
+ RSpec/Yield:
210
+ Enabled: true
211
+
212
+ RSpec/Dialect:
213
+ Enabled: true
214
+ PreferredMethods:
215
+ background: :before
216
+ scenario: :it
217
+ xscenario: :xit
218
+ given: :let
219
+ given!: :let!
220
+ feature: :describe
data/stree-compat.yml ADDED
@@ -0,0 +1,7 @@
1
+ inherit_from:
2
+ - ./rubocop-core.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: "3.3"
6
+ SuggestExtensions: false
7
+ DisabledByDefault: true
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubocop-discourse-base
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Discourse Team
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rubocop
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 1.80.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: 1.80.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: rake
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: 13.1.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 13.1.0
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - LICENSE
45
+ - README.md
46
+ - default.yml
47
+ - lib/rubocop/discourse/base.rb
48
+ - lib/rubocop/discourse/base/version.rb
49
+ - rubocop-core.yml
50
+ - rubocop-discourse-base.gemspec
51
+ - rubocop-layout.yml
52
+ - rubocop-rspec.yml
53
+ - stree-compat.yml
54
+ homepage: https://github.com/discourse/rubocop-discourse-base
55
+ licenses:
56
+ - MIT
57
+ metadata: {}
58
+ rdoc_options: []
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ version: '3.0'
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ requirements: []
72
+ rubygems_version: 3.6.9
73
+ specification_version: 4
74
+ summary: Common RuboCop configurations used by Discourse
75
+ test_files: []