rubocop-bridgetown 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +120 -0
- data/LICENSE +22 -0
- data/README.md +60 -0
- data/lib/rubocop/cop/bridgetown/no_p_allowed.rb +17 -0
- data/lib/rubocop/cop/bridgetown/no_puts_allowed.rb +17 -0
- data/lib/rubocop-bridgetown.rb +4 -0
- metadata +111 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: a3a7dee5454525c643ca51d52cce8fa3f8e98ee110d2be908f62c6e9d8920498
|
4
|
+
data.tar.gz: 4af89bab63caab938eba043e72838b231a52dbe5cb986df81c232e81b3c6e7c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fff6f1ed9f0b480b9b72009ac7db5f9f3053f148aa436ccd14bc440489284f31e58d74215a8f10f832702101c36fe099a49ac9d66e352a6e36de95e18c3f293e
|
7
|
+
data.tar.gz: d62342a1704a935359ac128b3468c6353e6980ac6aeceff867665cd1f5ada7bf371070e533503c72b94d9c00729410a02a9181aa13b965821af5aedbc4052340
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-performance
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 2.5
|
6
|
+
Exclude:
|
7
|
+
- bin/**/*
|
8
|
+
- exe/**/*
|
9
|
+
- benchmark/**/*
|
10
|
+
- script/**/*
|
11
|
+
- vendor/**/*
|
12
|
+
- tmp/**/*
|
13
|
+
|
14
|
+
Layout/HashAlignment:
|
15
|
+
EnforcedHashRocketStyle: table
|
16
|
+
Layout/IndentationWidth:
|
17
|
+
Severity: error
|
18
|
+
Layout/FirstArrayElementIndentation:
|
19
|
+
EnforcedStyle: consistent
|
20
|
+
Layout/FirstHashElementIndentation:
|
21
|
+
EnforcedStyle: consistent
|
22
|
+
Layout/MultilineMethodCallIndentation:
|
23
|
+
EnforcedStyle: indented
|
24
|
+
Layout/MultilineOperationIndentation:
|
25
|
+
EnforcedStyle: indented
|
26
|
+
Layout/EmptyComment:
|
27
|
+
Enabled: false
|
28
|
+
Layout/EndAlignment:
|
29
|
+
Severity: error
|
30
|
+
Lint/RaiseException:
|
31
|
+
Enabled: true
|
32
|
+
Lint/StructNewOverride:
|
33
|
+
Enabled: true
|
34
|
+
Lint/UnreachableCode:
|
35
|
+
Severity: error
|
36
|
+
Metrics/AbcSize:
|
37
|
+
Max: 21
|
38
|
+
Metrics/ClassLength:
|
39
|
+
Max: 240
|
40
|
+
Layout/LineLength:
|
41
|
+
Max: 100
|
42
|
+
Severity: warning
|
43
|
+
Metrics/MethodLength:
|
44
|
+
CountComments: false
|
45
|
+
Max: 20
|
46
|
+
Severity: error
|
47
|
+
Metrics/ModuleLength:
|
48
|
+
Max: 240
|
49
|
+
Metrics/ParameterLists:
|
50
|
+
Max: 4
|
51
|
+
Metrics/PerceivedComplexity:
|
52
|
+
Max: 8
|
53
|
+
Naming/FileName:
|
54
|
+
Enabled: false
|
55
|
+
Naming/MemoizedInstanceVariableName:
|
56
|
+
Enabled: false
|
57
|
+
Style/AccessModifierDeclarations:
|
58
|
+
Enabled: false
|
59
|
+
Style/Alias:
|
60
|
+
EnforcedStyle: prefer_alias_method
|
61
|
+
Style/AndOr:
|
62
|
+
Severity: error
|
63
|
+
Style/FrozenStringLiteralComment:
|
64
|
+
EnforcedStyle: always
|
65
|
+
Style/Documentation:
|
66
|
+
Enabled: false
|
67
|
+
Style/DoubleNegation:
|
68
|
+
Enabled: false
|
69
|
+
Style/GuardClause:
|
70
|
+
Enabled: false
|
71
|
+
Style/HashEachMethods:
|
72
|
+
Enabled: true
|
73
|
+
Style/HashSyntax: # This now adheres to GitHub's newest Ruby style guide
|
74
|
+
EnforcedStyle: ruby19
|
75
|
+
SupportedStyles:
|
76
|
+
# checks for 1.9 syntax (e.g. {a: 1}) for all symbol keys
|
77
|
+
- ruby19
|
78
|
+
# checks for hash rocket syntax for all hashes
|
79
|
+
- hash_rockets
|
80
|
+
# forbids mixed key syntaxes (e.g. {a: 1, :b => 2})
|
81
|
+
- no_mixed_keys
|
82
|
+
# enforces both ruby19 and no_mixed_keys styles
|
83
|
+
- ruby19_no_mixed_keys
|
84
|
+
# Force hashes that have a symbol value to use hash rockets
|
85
|
+
UseHashRocketsWithSymbolValues: false
|
86
|
+
# Do not suggest { a?: 1 } over { :a? => 1 } in ruby19 style
|
87
|
+
PreferHashRocketsForNonAlnumEndingSymbols: false
|
88
|
+
Style/HashTransformKeys:
|
89
|
+
Enabled: false
|
90
|
+
Style/HashTransformValues:
|
91
|
+
Enabled: true
|
92
|
+
Style/ModuleFunction:
|
93
|
+
Enabled: false
|
94
|
+
Style/MultilineTernaryOperator:
|
95
|
+
Severity: error
|
96
|
+
Style/PercentLiteralDelimiters:
|
97
|
+
PreferredDelimiters:
|
98
|
+
"%q": "{}"
|
99
|
+
"%Q": "{}"
|
100
|
+
"%r": "!!"
|
101
|
+
"%s": "()"
|
102
|
+
"%w": "()"
|
103
|
+
"%W": "()"
|
104
|
+
"%x": "()"
|
105
|
+
Style/RegexpLiteral:
|
106
|
+
EnforcedStyle: percent_r
|
107
|
+
Style/RescueModifier:
|
108
|
+
Enabled: false
|
109
|
+
Style/SignalException:
|
110
|
+
EnforcedStyle: only_raise
|
111
|
+
Style/StringLiterals:
|
112
|
+
EnforcedStyle: double_quotes
|
113
|
+
Style/StringLiteralsInInterpolation:
|
114
|
+
EnforcedStyle: double_quotes
|
115
|
+
Style/SymbolArray:
|
116
|
+
EnforcedStyle: brackets
|
117
|
+
Style/TrailingCommaInArrayLiteral:
|
118
|
+
EnforcedStyleForMultiline: consistent_comma
|
119
|
+
Style/TrailingCommaInHashLiteral:
|
120
|
+
EnforcedStyleForMultiline: consistent_comma
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020-present Jared White and Bridgetown contributors
|
4
|
+
Copyright (c) 2018-2020 Ashwin Maroli & Contributors
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
8
|
+
in the Software without restriction, including without limitation the rights
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
11
|
+
furnished to do so, subject to the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be included in
|
14
|
+
all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# RuboCop Bridgetown
|
2
|
+
|
3
|
+
A RuboCop extension to enforce common code style in Bridgetown plugins.
|
4
|
+
|
5
|
+
[![Gem Version](https://img.shields.io/gem/v/rubocop-bridgetown.svg?label=Latest%20Release)][rubygems]
|
6
|
+
[![RuboCop Support](https://img.shields.io/badge/Rubocop%20Support-0.68.0%20--%200.80.x-green.svg)][rubocop-releases]
|
7
|
+
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Just install the `rubocop-bridgetown` gem
|
12
|
+
|
13
|
+
```
|
14
|
+
gem install rubocop-bridgetown
|
15
|
+
```
|
16
|
+
|
17
|
+
or if you prefer Bundler, add it to your `Gemfile` or `gemspec`
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
# Gemfile
|
21
|
+
|
22
|
+
gem "rubocop-bridgetown", "~> 0.1.0"
|
23
|
+
```
|
24
|
+
```ruby
|
25
|
+
# <plugin>.gemspec
|
26
|
+
|
27
|
+
spec.add_development_dependency "rubocop-bridgetown", "~> 0.1.0"
|
28
|
+
```
|
29
|
+
and run `bundle install`
|
30
|
+
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
You need to tell RuboCop to load the extension and *inherit* the custom RuboCop configuration advocated by
|
35
|
+
[Bridgetown](https://github.com/bridgetown).
|
36
|
+
|
37
|
+
Place the following at the top of your `.rubocop.yml`.
|
38
|
+
|
39
|
+
```yaml
|
40
|
+
require: rubocop-bridgetown
|
41
|
+
inherit_gem:
|
42
|
+
rubocop-bridgetown: .rubocop.yml
|
43
|
+
```
|
44
|
+
|
45
|
+
Running `bundle exec rubocop` will now automatically load the `rubocop-bridgetown` cops together with the standard cops.
|
46
|
+
|
47
|
+
|
48
|
+
## Customization
|
49
|
+
|
50
|
+
You can override any settings inherited from the extension by subsequently redefining the concerned parameters.
|
51
|
+
|
52
|
+
|
53
|
+
## Release Cycle
|
54
|
+
|
55
|
+
A new release of this gem is manually cut based on the adoption of the latest version of RuboCop by the [Bridgetown repository](https://github.com/bridgetownrb/bridgetown):
|
56
|
+
|
57
|
+
1. RuboCop releases a new version.
|
58
|
+
2. The `master` branch of Bridgetown repository is updated to the latest RuboCop version along with any updates to their `.rubocop.yml`.
|
59
|
+
3. The RuboCop version and `.rubocop.yml` at this gem's repository is updated **via a pull request**.
|
60
|
+
4. A new minor release is subsequently cut and shipped.
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Bridgetown
|
6
|
+
class NoPAllowed < Cop
|
7
|
+
MSG = "Avoid using `p` to print things. Use `Bridgetown.logger` instead."
|
8
|
+
|
9
|
+
def_node_search :p_called?, "(send _ :p _)"
|
10
|
+
|
11
|
+
def on_send(node)
|
12
|
+
add_offense(node, :location => :selector) if p_called?(node)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RuboCop
|
4
|
+
module Cop
|
5
|
+
module Bridgetown
|
6
|
+
class NoPutsAllowed < Cop
|
7
|
+
MSG = "Avoid using `puts` to print things. Use `Bridgetown.logger` instead."
|
8
|
+
|
9
|
+
def_node_search :puts_called?, "(send nil? :puts _)"
|
10
|
+
|
11
|
+
def on_send(node)
|
12
|
+
add_offense(node, :location => :selector) if puts_called?(node)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubocop-bridgetown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bridgetown Team
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-05-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rubocop
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.68.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.81.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.68.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.81.0
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rubocop-performance
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.2'
|
40
|
+
type: :runtime
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '1.2'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: rake
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '12.0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '12.0'
|
75
|
+
description: A RuboCop extension to enforce common code style in Bridgetown plugins
|
76
|
+
email:
|
77
|
+
- maintainers@bridgetownrb.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- ".rubocop.yml"
|
83
|
+
- LICENSE
|
84
|
+
- README.md
|
85
|
+
- lib/rubocop-bridgetown.rb
|
86
|
+
- lib/rubocop/cop/bridgetown/no_p_allowed.rb
|
87
|
+
- lib/rubocop/cop/bridgetown/no_puts_allowed.rb
|
88
|
+
homepage: https://github.com/bridgetownrb/rubocop-bridgetown
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 2.5.0
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubygems_version: 3.0.8
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: Code style check for Bridgetown plugins
|
111
|
+
test_files: []
|