rubocop-boochtek 0.2.0 → 0.2.1
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 +4 -4
- data/.rubocop.yml +115 -5
- data/LICENSE.md +2 -2
- data/README.md +53 -106
- data/lib/disable_ssl_verify.rb +5 -0
- data/lib/extensions/argf.rb +8 -0
- data/lib/extensions/boolean.rb +48 -0
- data/lib/extensions/class.rb +10 -0
- data/lib/extensions/enumerable.rb +42 -0
- data/lib/extensions/integer.rb +7 -0
- data/lib/extensions/llvm_module.rb +101 -0
- data/lib/extensions/module.rb +34 -0
- data/lib/extensions/string.rb +29 -0
- data/lib/stone/ast/block.rb +88 -0
- data/lib/stone/ast/boolean_literal.rb +43 -0
- data/lib/stone/ast/computed_property_definition.rb +32 -0
- data/lib/stone/ast/constant_definition.rb +124 -0
- data/lib/stone/ast/expression.rb +12 -0
- data/lib/stone/ast/function_call.rb +291 -0
- data/lib/stone/ast/function_type_annotation.rb +31 -0
- data/lib/stone/ast/integer_literal.rb +46 -0
- data/lib/stone/ast/lambda.rb +126 -0
- data/lib/stone/ast/null_literal.rb +29 -0
- data/lib/stone/ast/program_unit/top_function.rb +209 -0
- data/lib/stone/ast/program_unit.rb +412 -0
- data/lib/stone/ast/property_access.rb +557 -0
- data/lib/stone/ast/record_definition.rb +180 -0
- data/lib/stone/ast/record_instantiation.rb +141 -0
- data/lib/stone/ast/reference.rb +145 -0
- data/lib/stone/ast/string_literal.rb +79 -0
- data/lib/stone/ast/two_phase_processing.rb +36 -0
- data/lib/stone/ast/type_annotation.rb +26 -0
- data/lib/stone/ast/type_declaration.rb +28 -0
- data/lib/stone/ast/type_of_expression.rb +41 -0
- data/lib/stone/ast/type_reference.rb +28 -0
- data/lib/stone/ast/union_type_annotation.rb +26 -0
- data/lib/stone/ast.rb +64 -0
- data/lib/stone/built_ins.rb +245 -0
- data/lib/stone/error/argument_error.rb +7 -0
- data/lib/stone/error/arity_error.rb +7 -0
- data/lib/stone/error/overflow.rb +18 -0
- data/lib/stone/error/property_error.rb +7 -0
- data/lib/stone/error/reference_error.rb +4 -0
- data/lib/stone/error/type_error.rb +7 -0
- data/lib/stone/error.rb +12 -0
- data/lib/stone/grammar.rb +124 -0
- data/lib/stone/libc.rb +27 -0
- data/lib/stone/prelude.stone +11 -0
- data/lib/stone/rtti.rb +182 -0
- data/lib/stone/scope.rb +85 -0
- data/lib/stone/transform.rb +410 -0
- data/lib/stone/type.rb +323 -0
- data/lib/stone/type_context.rb +38 -0
- data/lib/stone/type_registry.rb +73 -0
- data/lib/stone/types.rb +104 -0
- data/lib/stone.rb +70 -0
- metadata +54 -24
- data/CHANGELOG.md +0 -28
- data/Rakefile +0 -5
- data/config/default.yml +0 -277
- data/lib/rubocop/boochtek/plugin.rb +0 -43
- data/lib/rubocop/boochtek/version.rb +0 -7
- data/lib/rubocop/boochtek.rb +0 -18
- data/lib/rubocop/cop/boochtek/compact_endless_methods.rb +0 -103
- data/lib/rubocop-boochtek.rb +0 -3
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubocop-boochtek
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Craig Buchek
|
|
@@ -65,20 +65,6 @@ dependencies:
|
|
|
65
65
|
- - "~>"
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: '3.0'
|
|
68
|
-
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: rspec
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - "~>"
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '3.13'
|
|
75
|
-
type: :development
|
|
76
|
-
prerelease: false
|
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - "~>"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '3.13'
|
|
82
68
|
description: Shared RuboCop configuration for BoochTek projects. Includes opinionated
|
|
83
69
|
defaults and support for custom cops.
|
|
84
70
|
email:
|
|
@@ -88,16 +74,60 @@ extensions: []
|
|
|
88
74
|
extra_rdoc_files: []
|
|
89
75
|
files:
|
|
90
76
|
- ".rubocop.yml"
|
|
91
|
-
- CHANGELOG.md
|
|
92
77
|
- LICENSE.md
|
|
93
78
|
- README.md
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
- lib/
|
|
97
|
-
- lib/
|
|
98
|
-
- lib/
|
|
99
|
-
- lib/
|
|
100
|
-
- lib/
|
|
79
|
+
- lib/disable_ssl_verify.rb
|
|
80
|
+
- lib/extensions/argf.rb
|
|
81
|
+
- lib/extensions/boolean.rb
|
|
82
|
+
- lib/extensions/class.rb
|
|
83
|
+
- lib/extensions/enumerable.rb
|
|
84
|
+
- lib/extensions/integer.rb
|
|
85
|
+
- lib/extensions/llvm_module.rb
|
|
86
|
+
- lib/extensions/module.rb
|
|
87
|
+
- lib/extensions/string.rb
|
|
88
|
+
- lib/stone.rb
|
|
89
|
+
- lib/stone/ast.rb
|
|
90
|
+
- lib/stone/ast/block.rb
|
|
91
|
+
- lib/stone/ast/boolean_literal.rb
|
|
92
|
+
- lib/stone/ast/computed_property_definition.rb
|
|
93
|
+
- lib/stone/ast/constant_definition.rb
|
|
94
|
+
- lib/stone/ast/expression.rb
|
|
95
|
+
- lib/stone/ast/function_call.rb
|
|
96
|
+
- lib/stone/ast/function_type_annotation.rb
|
|
97
|
+
- lib/stone/ast/integer_literal.rb
|
|
98
|
+
- lib/stone/ast/lambda.rb
|
|
99
|
+
- lib/stone/ast/null_literal.rb
|
|
100
|
+
- lib/stone/ast/program_unit.rb
|
|
101
|
+
- lib/stone/ast/program_unit/top_function.rb
|
|
102
|
+
- lib/stone/ast/property_access.rb
|
|
103
|
+
- lib/stone/ast/record_definition.rb
|
|
104
|
+
- lib/stone/ast/record_instantiation.rb
|
|
105
|
+
- lib/stone/ast/reference.rb
|
|
106
|
+
- lib/stone/ast/string_literal.rb
|
|
107
|
+
- lib/stone/ast/two_phase_processing.rb
|
|
108
|
+
- lib/stone/ast/type_annotation.rb
|
|
109
|
+
- lib/stone/ast/type_declaration.rb
|
|
110
|
+
- lib/stone/ast/type_of_expression.rb
|
|
111
|
+
- lib/stone/ast/type_reference.rb
|
|
112
|
+
- lib/stone/ast/union_type_annotation.rb
|
|
113
|
+
- lib/stone/built_ins.rb
|
|
114
|
+
- lib/stone/error.rb
|
|
115
|
+
- lib/stone/error/argument_error.rb
|
|
116
|
+
- lib/stone/error/arity_error.rb
|
|
117
|
+
- lib/stone/error/overflow.rb
|
|
118
|
+
- lib/stone/error/property_error.rb
|
|
119
|
+
- lib/stone/error/reference_error.rb
|
|
120
|
+
- lib/stone/error/type_error.rb
|
|
121
|
+
- lib/stone/grammar.rb
|
|
122
|
+
- lib/stone/libc.rb
|
|
123
|
+
- lib/stone/prelude.stone
|
|
124
|
+
- lib/stone/rtti.rb
|
|
125
|
+
- lib/stone/scope.rb
|
|
126
|
+
- lib/stone/transform.rb
|
|
127
|
+
- lib/stone/type.rb
|
|
128
|
+
- lib/stone/type_context.rb
|
|
129
|
+
- lib/stone/type_registry.rb
|
|
130
|
+
- lib/stone/types.rb
|
|
101
131
|
homepage: https://github.com/boochtek/rubocop-boochtek
|
|
102
132
|
licenses:
|
|
103
133
|
- MIT
|
|
@@ -121,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
121
151
|
- !ruby/object:Gem::Version
|
|
122
152
|
version: '0'
|
|
123
153
|
requirements: []
|
|
124
|
-
rubygems_version:
|
|
154
|
+
rubygems_version: 4.0.3
|
|
125
155
|
specification_version: 4
|
|
126
156
|
summary: BoochTek's RuboCop configuration and custom cops
|
|
127
157
|
test_files: []
|
data/CHANGELOG.md
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## [Unreleased]
|
|
9
|
-
|
|
10
|
-
## [0.2.0] - 2025-12-06
|
|
11
|
-
|
|
12
|
-
### Added
|
|
13
|
-
- New custom cop `Boochtek/CompactEndlessMethods` - removes blank lines between consecutive endless method definitions
|
|
14
|
-
- Comprehensive test suite with RSpec for the custom cop
|
|
15
|
-
- Support for both instance methods (`def foo = @foo`) and class methods (`def self.foo = "foo"`)
|
|
16
|
-
|
|
17
|
-
### Changed
|
|
18
|
-
- Updated gemspec to explicitly list included files instead of using `git ls-files`
|
|
19
|
-
- Added RSpec as a development dependency
|
|
20
|
-
|
|
21
|
-
## [0.1.0] - 2024-12-05
|
|
22
|
-
|
|
23
|
-
### Added
|
|
24
|
-
- Initial release
|
|
25
|
-
- Base RuboCop configuration extracted from BoochTek projects
|
|
26
|
-
- LintRoller plugin for modern RuboCop (1.72+)
|
|
27
|
-
- Dependencies on rubocop-rspec and rubocop-performance
|
|
28
|
-
- Support for custom cops in `lib/rubocop/cop/boochtek/`
|
data/Rakefile
DELETED
data/config/default.yml
DELETED
|
@@ -1,277 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
# BoochTek's RuboCop Configuration
|
|
3
|
-
# https://github.com/boochtek/rubocop-boochtek
|
|
4
|
-
|
|
5
|
-
plugins:
|
|
6
|
-
- rubocop-performance
|
|
7
|
-
- rubocop-rspec
|
|
8
|
-
|
|
9
|
-
# Provide more details in output.
|
|
10
|
-
AllCops:
|
|
11
|
-
DisplayCopNames: true
|
|
12
|
-
DisplayStyleGuide: true
|
|
13
|
-
ExtraDetails: true
|
|
14
|
-
NewCops: pending
|
|
15
|
-
SuggestExtensions: false
|
|
16
|
-
|
|
17
|
-
# Gem convention uses hyphens in filenames.
|
|
18
|
-
Naming/FileName:
|
|
19
|
-
Exclude:
|
|
20
|
-
- "**/rubocop-*.rb"
|
|
21
|
-
|
|
22
|
-
# Allow longer lines.
|
|
23
|
-
Layout/LineLength:
|
|
24
|
-
Max: 120
|
|
25
|
-
|
|
26
|
-
# Don't require documentation for everything.
|
|
27
|
-
Style/Documentation:
|
|
28
|
-
Enabled: false
|
|
29
|
-
|
|
30
|
-
# Allow any Unicode in comments.
|
|
31
|
-
Style/AsciiComments:
|
|
32
|
-
Enabled: false
|
|
33
|
-
|
|
34
|
-
# Require `private` to be used as a prefix to private method definitions.
|
|
35
|
-
# We find this easier to read and move code.
|
|
36
|
-
Style/AccessModifierDeclarations:
|
|
37
|
-
EnforcedStyle: inline
|
|
38
|
-
|
|
39
|
-
# Use `{}` for blocks that return a value; otherwise use `do` and `end`.
|
|
40
|
-
# We make a few exceptions, mostly for RSpec and DSLs.
|
|
41
|
-
Style/BlockDelimiters:
|
|
42
|
-
EnforcedStyle: semantic
|
|
43
|
-
FunctionalMethods:
|
|
44
|
-
- expect
|
|
45
|
-
AllowedMethods:
|
|
46
|
-
# RSpec
|
|
47
|
-
- let
|
|
48
|
-
- let!
|
|
49
|
-
- subject
|
|
50
|
-
# DSL methods (grammar/parser DSLs)
|
|
51
|
-
- rule
|
|
52
|
-
- rule!
|
|
53
|
-
- token
|
|
54
|
-
- terminal
|
|
55
|
-
- terminal!
|
|
56
|
-
- grammar
|
|
57
|
-
- transforms
|
|
58
|
-
- transform
|
|
59
|
-
|
|
60
|
-
# Don't require `freeze` on every immutable constant.
|
|
61
|
-
Style/MutableConstant:
|
|
62
|
-
Enabled: false
|
|
63
|
-
|
|
64
|
-
# Don't require adding `# frozen_string_literal: true` to every file.
|
|
65
|
-
Style/FrozenStringLiteralComment:
|
|
66
|
-
Enabled: false
|
|
67
|
-
|
|
68
|
-
# Don't use backticks for shell commands -- they're too hard to distinguish.
|
|
69
|
-
Style/CommandLiteral:
|
|
70
|
-
EnforcedStyle: percent_x
|
|
71
|
-
|
|
72
|
-
# Don't require underscores for long numeric literals (but warn about them).
|
|
73
|
-
Style/NumericLiterals:
|
|
74
|
-
Severity: warning
|
|
75
|
-
|
|
76
|
-
# Allow (but don't require) extra empty lines.
|
|
77
|
-
Layout/EmptyLines:
|
|
78
|
-
Enabled: false
|
|
79
|
-
|
|
80
|
-
# Don't require empty methods to have the `def` and `end` on a single line.
|
|
81
|
-
Style/EmptyMethod:
|
|
82
|
-
Enabled: false
|
|
83
|
-
|
|
84
|
-
# Use `[]` for `%w`, to remind us that we're creating an Array.
|
|
85
|
-
# Use `[]` for `%x`, because it looks kind of like an input box.
|
|
86
|
-
# Use `{}` for `%q`, because it's set off a bit nicer than `()`.
|
|
87
|
-
# Use `{}` for `%r`, because regular expressions might have unbalanced `()` or `<>`.
|
|
88
|
-
Style/PercentLiteralDelimiters:
|
|
89
|
-
PreferredDelimiters:
|
|
90
|
-
'%w': '[]'
|
|
91
|
-
'%W': '[]'
|
|
92
|
-
'%x': '[]'
|
|
93
|
-
'%': '{}'
|
|
94
|
-
'%q': '{}'
|
|
95
|
-
'%Q': '{}'
|
|
96
|
-
'%r': '{}'
|
|
97
|
-
|
|
98
|
-
# Allow explicit `self`, as it adds clarity on occasion.
|
|
99
|
-
Style/RedundantSelf:
|
|
100
|
-
Enabled: false
|
|
101
|
-
|
|
102
|
-
# Use `%r` for regular expressions that span more than 1 line.
|
|
103
|
-
Style/RegexpLiteral:
|
|
104
|
-
EnforcedStyle: mixed
|
|
105
|
-
|
|
106
|
-
# Use Jim Weirich's suggestion of using `fail`, except when re-raising an exception.
|
|
107
|
-
Style/SignalException:
|
|
108
|
-
EnforcedStyle: semantic
|
|
109
|
-
|
|
110
|
-
# Provide a better description, due to high probability of false positives.
|
|
111
|
-
Lint/RaiseException:
|
|
112
|
-
Enabled: true
|
|
113
|
-
Description: Use `StandardError`, or prefix `Exception` with a namespace.
|
|
114
|
-
|
|
115
|
-
# Default to double quotes, as they require less incidental changes.
|
|
116
|
-
Style/StringLiterals:
|
|
117
|
-
EnforcedStyle: double_quotes
|
|
118
|
-
|
|
119
|
-
# Allow either type of quotes within Ruby code inside interpolations.
|
|
120
|
-
Style/StringLiteralsInInterpolation:
|
|
121
|
-
Enabled: false
|
|
122
|
-
|
|
123
|
-
# Allow (but don't require) a space before a block brace.
|
|
124
|
-
Layout/SpaceBeforeBlockBraces:
|
|
125
|
-
Enabled: false
|
|
126
|
-
|
|
127
|
-
# Don't allow a space directly inside a Hash literal.
|
|
128
|
-
Layout/SpaceInsideHashLiteralBraces:
|
|
129
|
-
EnforcedStyle: no_space
|
|
130
|
-
|
|
131
|
-
# Require a space directly inside a block delineated with braces.
|
|
132
|
-
# This is the default, but I wanted to call it out in contrast to Hash literals.
|
|
133
|
-
Layout/SpaceInsideBlockBraces:
|
|
134
|
-
EnforcedStyle: space
|
|
135
|
-
EnforcedStyleForEmptyBraces: no_space
|
|
136
|
-
SpaceBeforeBlockParameters: true
|
|
137
|
-
|
|
138
|
-
# When using multi-line Arrays and Hashes, ensure the first element is also on its own line.
|
|
139
|
-
Layout/FirstArrayElementLineBreak:
|
|
140
|
-
Enabled: true
|
|
141
|
-
Layout/FirstHashElementLineBreak:
|
|
142
|
-
Enabled: true
|
|
143
|
-
|
|
144
|
-
# Allow (but don't require) trailing comma in Array and Hash literals.
|
|
145
|
-
Style/TrailingCommaInArrayLiteral:
|
|
146
|
-
Enabled: false
|
|
147
|
-
Style/TrailingCommaInHashLiteral:
|
|
148
|
-
Enabled: false
|
|
149
|
-
|
|
150
|
-
# Don't complain about the block comments generated by RSpec.
|
|
151
|
-
Style/BlockComments:
|
|
152
|
-
Exclude:
|
|
153
|
-
- 'spec/spec_helper.rb'
|
|
154
|
-
|
|
155
|
-
# Prefer `__send__` or `public_send` over `send`.
|
|
156
|
-
Style/Send:
|
|
157
|
-
Enabled: true
|
|
158
|
-
|
|
159
|
-
# Don't complain that `has_many` doesn't end with a question mark.
|
|
160
|
-
Naming/PredicatePrefix:
|
|
161
|
-
AllowedMethods:
|
|
162
|
-
- is_a?
|
|
163
|
-
- has_many
|
|
164
|
-
- has_rule?
|
|
165
|
-
|
|
166
|
-
# Allow `has_key?` and `has_value?` on Hash, as I think they read better than `key?` and `value?`.
|
|
167
|
-
Style/PreferredHashMethods:
|
|
168
|
-
Enabled: false
|
|
169
|
-
|
|
170
|
-
# Ensure there's a newline at the end of the file, but not a blank line.
|
|
171
|
-
Layout/TrailingEmptyLines:
|
|
172
|
-
EnforcedStyle: final_newline
|
|
173
|
-
|
|
174
|
-
# Allow assigning to the same variable in multiple branches of an `if` or `case`.
|
|
175
|
-
Style/ConditionalAssignment:
|
|
176
|
-
Enabled: false
|
|
177
|
-
|
|
178
|
-
# Allow long blocks in specs and tests.
|
|
179
|
-
Metrics/BlockLength:
|
|
180
|
-
Exclude:
|
|
181
|
-
- spec/**/*
|
|
182
|
-
- test/**/*
|
|
183
|
-
|
|
184
|
-
# Don't require use of Ruby 2.3+ safe navigation operator.
|
|
185
|
-
Style/SafeNavigation:
|
|
186
|
-
Enabled: false
|
|
187
|
-
|
|
188
|
-
# Allow `!!` to force a boolean result.
|
|
189
|
-
Style/DoubleNegation:
|
|
190
|
-
Enabled: false
|
|
191
|
-
|
|
192
|
-
# I prefer to order my gems in order of "importance".
|
|
193
|
-
Bundler/OrderedGems:
|
|
194
|
-
Enabled: false
|
|
195
|
-
|
|
196
|
-
# Don't require an empty line after a guard clause.
|
|
197
|
-
Layout/EmptyLineAfterGuardClause:
|
|
198
|
-
Enabled: false
|
|
199
|
-
|
|
200
|
-
# Allow (but don't require) putting each accessor on its own line.
|
|
201
|
-
Style/AccessorGrouping:
|
|
202
|
-
Enabled: false
|
|
203
|
-
|
|
204
|
-
# I don't see any good reason to call `super` when the superclass has no explicit `initialize`.
|
|
205
|
-
# See https://github.com/rubocop-hq/rubocop/issues/8506 for more details.
|
|
206
|
-
Lint/MissingSuper:
|
|
207
|
-
Enabled: false
|
|
208
|
-
|
|
209
|
-
# Don't require any specific format when using exponential notation (like `10e6` or `1.0e7`).
|
|
210
|
-
Style/ExponentialNotation:
|
|
211
|
-
Enabled: false
|
|
212
|
-
|
|
213
|
-
# Allow `nil` to be the only thing inside a lambda block.
|
|
214
|
-
Style/NilLambda:
|
|
215
|
-
Enabled: false
|
|
216
|
-
|
|
217
|
-
# Allow `chars.last(count)` and `chars.drop(count)` on String.
|
|
218
|
-
Performance/RedundantStringChars:
|
|
219
|
-
Enabled: false
|
|
220
|
-
|
|
221
|
-
# Allow passing a method object as a block (using `&` and `method`).
|
|
222
|
-
Performance/MethodObjectAsBlock:
|
|
223
|
-
Enabled: false
|
|
224
|
-
|
|
225
|
-
# Prefer `class X < Data.define(...)` over `X = Data.define(...)`.
|
|
226
|
-
# It makes nested constants work as expected.
|
|
227
|
-
# See https://allaboutcoding.ghinda.com/more-about-how-to-create-a-data-class-in-ruby for details.
|
|
228
|
-
Style/DataInheritance:
|
|
229
|
-
Enabled: false
|
|
230
|
-
|
|
231
|
-
# Allow long specs.
|
|
232
|
-
Metrics/ModuleLength:
|
|
233
|
-
Exclude:
|
|
234
|
-
- 'spec/**/*'
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
# =============================================================================
|
|
238
|
-
# BoochTek Custom Cops
|
|
239
|
-
# =============================================================================
|
|
240
|
-
|
|
241
|
-
# Remove blank lines between consecutive endless (one-liner) method definitions.
|
|
242
|
-
Boochtek/CompactEndlessMethods:
|
|
243
|
-
Enabled: true
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
# =============================================================================
|
|
247
|
-
# RSpec Configuration
|
|
248
|
-
# =============================================================================
|
|
249
|
-
|
|
250
|
-
RSpec/MultipleExpectations:
|
|
251
|
-
Max: 10
|
|
252
|
-
|
|
253
|
-
RSpec/ExampleLength:
|
|
254
|
-
Max: 10
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
# =============================================================================
|
|
258
|
-
# Workarounds for RuboCop bugs
|
|
259
|
-
# =============================================================================
|
|
260
|
-
|
|
261
|
-
# These cops seem to be broken; I *have* empty lines around class/module/block bodies.
|
|
262
|
-
Layout/EmptyLinesAroundClassBody:
|
|
263
|
-
Enabled: false
|
|
264
|
-
Layout/EmptyLinesAroundModuleBody:
|
|
265
|
-
Enabled: false
|
|
266
|
-
Layout/EmptyLineBetweenDefs:
|
|
267
|
-
Enabled: false
|
|
268
|
-
Layout/EmptyLinesAroundBlockBody:
|
|
269
|
-
Enabled: false
|
|
270
|
-
|
|
271
|
-
# This is broken. It assumes that a comment following a `private def` should be indented 2 extra spaces.
|
|
272
|
-
Layout/CommentIndentation:
|
|
273
|
-
Enabled: false
|
|
274
|
-
|
|
275
|
-
# This rule requires arrays in arguments to be formatted poorly.
|
|
276
|
-
Layout/FirstArrayElementIndentation:
|
|
277
|
-
Enabled: false
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "lint_roller"
|
|
4
|
-
require_relative "version"
|
|
5
|
-
|
|
6
|
-
# Load custom cops
|
|
7
|
-
cop_dir = File.expand_path("../cop/boochtek", __dir__)
|
|
8
|
-
if File.directory?(cop_dir)
|
|
9
|
-
Dir.glob(File.join(cop_dir, "**", "*.rb")).each do |cop_file|
|
|
10
|
-
require cop_file
|
|
11
|
-
end
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
module RuboCop
|
|
15
|
-
module Boochtek
|
|
16
|
-
class Plugin < LintRoller::Plugin
|
|
17
|
-
def about
|
|
18
|
-
LintRoller::About.new(
|
|
19
|
-
name: "rubocop-boochtek",
|
|
20
|
-
version: VERSION,
|
|
21
|
-
homepage: "https://github.com/boochtek/rubocop-boochtek",
|
|
22
|
-
description: "BoochTek's RuboCop configuration and custom cops"
|
|
23
|
-
)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def supported?(context)
|
|
27
|
-
context.engine == :rubocop
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def rules(_context)
|
|
31
|
-
LintRoller::Rules.new(
|
|
32
|
-
type: :path,
|
|
33
|
-
config_format: :rubocop,
|
|
34
|
-
value: config_path
|
|
35
|
-
)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
private def config_path
|
|
39
|
-
File.expand_path("../../../config/default.yml", __dir__)
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
end
|
data/lib/rubocop/boochtek.rb
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "boochtek/version"
|
|
4
|
-
require_relative "boochtek/plugin"
|
|
5
|
-
|
|
6
|
-
module RuboCop
|
|
7
|
-
module Boochtek
|
|
8
|
-
class Error < StandardError; end
|
|
9
|
-
|
|
10
|
-
# Auto-discover and load custom cops from lib/rubocop/cop/boochtek/
|
|
11
|
-
COP_DIR = File.expand_path("cop/boochtek", __dir__)
|
|
12
|
-
if File.directory?(COP_DIR)
|
|
13
|
-
Dir.glob(File.join(COP_DIR, "**", "*.rb")).each do |cop_file|
|
|
14
|
-
require cop_file
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module RuboCop
|
|
4
|
-
module Cop
|
|
5
|
-
module Boochtek
|
|
6
|
-
# Removes blank lines between consecutive endless (one-liner) method definitions.
|
|
7
|
-
#
|
|
8
|
-
# This cop allows grouping related endless methods together without
|
|
9
|
-
# the blank line that `Layout/EmptyLineBetweenDefs` normally requires.
|
|
10
|
-
#
|
|
11
|
-
# @example
|
|
12
|
-
# # bad
|
|
13
|
-
# def foo = @foo
|
|
14
|
-
#
|
|
15
|
-
# def bar = @bar
|
|
16
|
-
#
|
|
17
|
-
# # good
|
|
18
|
-
# def foo = @foo
|
|
19
|
-
# def bar = @bar
|
|
20
|
-
#
|
|
21
|
-
# # good - blank line between endless and regular method is fine
|
|
22
|
-
# def foo = @foo
|
|
23
|
-
#
|
|
24
|
-
# def bar
|
|
25
|
-
# @bar
|
|
26
|
-
# end
|
|
27
|
-
#
|
|
28
|
-
class CompactEndlessMethods < Base
|
|
29
|
-
extend AutoCorrector
|
|
30
|
-
|
|
31
|
-
MSG = "Remove blank line between consecutive endless methods."
|
|
32
|
-
|
|
33
|
-
def on_def(node)
|
|
34
|
-
check_endless_method(node)
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
def on_defs(node)
|
|
38
|
-
check_endless_method(node)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
private
|
|
42
|
-
|
|
43
|
-
def check_endless_method(node)
|
|
44
|
-
return unless endless_def?(node)
|
|
45
|
-
|
|
46
|
-
prev_sibling = previous_sibling_def(node)
|
|
47
|
-
return unless prev_sibling
|
|
48
|
-
return unless endless_def?(prev_sibling)
|
|
49
|
-
|
|
50
|
-
blank_lines = blank_lines_between(prev_sibling, node)
|
|
51
|
-
return if blank_lines.empty?
|
|
52
|
-
|
|
53
|
-
add_offense(node) do |corrector|
|
|
54
|
-
blank_lines.each do |line_range|
|
|
55
|
-
corrector.remove(line_range)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def endless_def?(node)
|
|
61
|
-
return false unless node&.def_type? || node&.defs_type?
|
|
62
|
-
|
|
63
|
-
node.endless?
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def previous_sibling_def(node)
|
|
67
|
-
return nil unless node.parent
|
|
68
|
-
|
|
69
|
-
siblings = node.parent.children
|
|
70
|
-
index = siblings.index(node)
|
|
71
|
-
return nil if index.nil? || index.zero?
|
|
72
|
-
|
|
73
|
-
prev = siblings[index - 1]
|
|
74
|
-
prev if prev&.def_type? || prev&.defs_type?
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def blank_lines_between(prev_node, current_node)
|
|
78
|
-
prev_end_line = prev_node.loc.expression.end.line
|
|
79
|
-
current_start_line = current_node.loc.expression.line
|
|
80
|
-
|
|
81
|
-
return [] if current_start_line <= prev_end_line + 1
|
|
82
|
-
|
|
83
|
-
blank_line_numbers = ((prev_end_line + 1)...current_start_line).to_a
|
|
84
|
-
return [] if blank_line_numbers.empty?
|
|
85
|
-
|
|
86
|
-
blank_line_numbers.map do |line_num|
|
|
87
|
-
line_begin = processed_source.buffer.line_range(line_num)
|
|
88
|
-
# Include the newline character
|
|
89
|
-
range_with_newline(line_begin)
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def range_with_newline(range)
|
|
94
|
-
Parser::Source::Range.new(
|
|
95
|
-
range.source_buffer,
|
|
96
|
-
range.begin_pos,
|
|
97
|
-
range.end_pos + 1
|
|
98
|
-
)
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
data/lib/rubocop-boochtek.rb
DELETED