rubocop-bridgetown 0.4.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c1c55c379762ea7310036dd92c1c6133257af4b161e3ad41d722e2acded33082
4
- data.tar.gz: 464b333e864028797b1975bbc21edb685043faf6449536190f05f163910a1bf4
3
+ metadata.gz: 77d5770855e6106a4b722873f8e11e505997617642aa247f5e3629a9e55a66a5
4
+ data.tar.gz: 006da9d177a2812008ddaf7f50cd39beb42d21b301f98e9da11452e1bd575685
5
5
  SHA512:
6
- metadata.gz: '094a43e9ab0e00667fe83e775bf9bc85a487df3308bcdc1692dbded1c3fe94599c9a278f0d6a283e4a4cc8da7db7af0fe2e1a688196b3816071b777330400ac9'
7
- data.tar.gz: 2870d7b4a58f7ab628978dcc3ed4e4ecebb1f37ca0e003e670d69764fd61ba3161224234e9312c5c1527b20226723fee958fa65609c084b422aaecb86abf1186
6
+ metadata.gz: 9e9ce63f05136e486de72593361f48479e450ea3894608e2104b2f98d1092ee7c0927a8512034010d8f720ea07c735e0ada0eea7021767a6b254277144ac0656
7
+ data.tar.gz: 690b96fa2e93606e1c9b3ea9a7a2d0d17e79046782397f5947595909df80e6d3a5e447659a3dd2464a9a67cd14e0a196ee0a44b82a89bada119f984ae87317fa
data/.rubocop.yml CHANGED
@@ -2,7 +2,7 @@ require:
2
2
  - rubocop-performance
3
3
 
4
4
  AllCops:
5
- TargetRubyVersion: 2.5
5
+ TargetRubyVersion: 3.1
6
6
  NewCops: enable
7
7
  SuggestExtensions: false
8
8
  Exclude:
@@ -26,6 +26,8 @@ Layout/HashAlignment:
26
26
  EnforcedHashRocketStyle: table
27
27
  Layout/IndentationWidth:
28
28
  Severity: error
29
+ Layout/LeadingCommentSpace:
30
+ Enabled: false
29
31
  Layout/MultilineMethodCallIndentation:
30
32
  EnforcedStyle: indented
31
33
  Layout/MultilineOperationIndentation:
@@ -73,12 +75,14 @@ Style/Lambda:
73
75
  EnforcedStyle: literal
74
76
  Style/LambdaCall:
75
77
  Enabled: false
78
+ Style/MixinGrouping:
79
+ Enabled: false
76
80
  Style/ModuleFunction:
77
81
  Enabled: false
78
82
  Style/MultilineBlockChain:
79
83
  Enabled: false
80
84
  Style/MultilineTernaryOperator:
81
- Severity: error
85
+ Enabled: false
82
86
  Style/ParallelAssignment:
83
87
  Enabled: false
84
88
  Style/PercentLiteralDelimiters:
data/README.md CHANGED
@@ -40,6 +40,8 @@ inherit_gem:
40
40
 
41
41
  Running `bundle exec rubocop` will now automatically load the `rubocop-bridgetown` cops together with the standard cops.
42
42
 
43
+ **Note:** if you want just the extra cops from this gem such as `Bridgetown/HTMLEscapedHeredoc` but wish to use your own configuration otherwise, you can omit the `inherit_gem` section entirely.
44
+
43
45
  You can also add a `rubocop` task to your `Rakefile`.
44
46
 
45
47
  ```ruby
@@ -72,8 +74,10 @@ You can override any settings inherited from the extension by configuring cops i
72
74
 
73
75
  Besides cops which are provided directly by RuboCop and `rubocop-performance`, there are a few additional cops provided by this plugin:
74
76
 
75
- * `Bridgetown/HTMLEscapedHeredoc`: this will monitor any heredocs in your code for potential XSS issues inside of any string interpolations. To avoid linting errors, you will need to wrap any interpolated code inside of one of the following method names: `html`, `html_map`, `html_attributes`, `text`, or `render`. These methods are provided by the [Streamlined](https://github.com/bridgetownrb/streamlined) gem, bundled in Bridgetown 1.4 by default (but you can use them in any Ruby application including Rails).
77
+ * `Bridgetown/InsecureHeredoc`: this will monitor any heredocs in your code starting with `HTML` or `MARKDOWN` for potential XSS issues inside of any string interpolations. To avoid linting errors, you will need to wrap any interpolated code in the string with one of the following method names: `html`, `html_map`, `html_attributes`, `text`, or `render`. These methods are provided by the [Streamlined](https://github.com/bridgetownrb/streamlined) gem, bundled in Bridgetown 2.0 by default (but you can use them in any Ruby application including Rails).
76
78
  * `Bridgetown/NoPAllowed`: this encourages using your framework's logger rather than `p` to output debugging information.
77
79
  * `Bridgetown/NoPutsAllowed`: this encourages using your framework's logger rather than `puts` to output debugging information.
78
80
 
79
81
  You can disable any of these cops in specific parts of your codebase as needed, or by setting `Enabled: false` for any particular cop in your `.rubocop.yml`.
82
+
83
+ Regarding recommended Streamlined syntax, you may want to exclude `Layout/SpaceBeforeFirstArg` and `Layout/SpaceBeforeBlockBraces` in the folders you write Streamlined components and helpers. This is so you can write `text->{ ... }`, `html->{ ... }`, etc. (Otherwise RuboCop will require you to write `text -> { ... }`, etc. which is more verbose.)
@@ -3,14 +3,17 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Bridgetown
6
- class HTMLEscapedHeredoc < Cop
6
+ class InsecureHeredoc < Base
7
7
  include Heredoc
8
8
 
9
- MSG = "Insecure heredoc detected. Use `html`, `html_map`, `html_attributes`, `text`, or `render` inside interpolations."
9
+ MSG = "Insecure heredoc detected. Use `html`, `html_map`, `html_attributes`, `text`, " \
10
+ "or `render` inside interpolations."
10
11
 
11
12
  def on_heredoc(node)
12
13
  return unless node.source.match?(%r!(HTML|MARKDOWN)$!) &&
13
- heredoc_body(node).match?(%r%[^\\]#\{(?!\s*?(html|html_map|html_attributes|text|render)[ \-\(])%)
14
+ heredoc_body(node).match?(
15
+ %r%[^\\]#\{(?!\s*?(html|html_map|html_attributes|text|render)[ \-\(])%
16
+ )
14
17
 
15
18
  add_offense(node, message: MSG)
16
19
  end
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Bridgetown
6
- class NoPAllowed < Cop
6
+ class NoPAllowed < Base
7
7
  MSG = "Avoid using `p` to print things. Use `Bridgetown.logger` instead."
8
8
 
9
9
  def_node_search :p_called?, "(send _ :p _)"
@@ -3,7 +3,7 @@
3
3
  module RuboCop
4
4
  module Cop
5
5
  module Bridgetown
6
- class NoPutsAllowed < Cop
6
+ class NoPutsAllowed < Base
7
7
  MSG = "Avoid using `puts` to print things. Use `Bridgetown.logger` instead."
8
8
 
9
9
  def_node_search :puts_called?, "(send nil? :puts _)"
@@ -3,4 +3,4 @@
3
3
  require "rubocop"
4
4
 
5
5
  path_to_cops = File.join(File.expand_path("rubocop", __dir__), "cop", "**", "*.rb")
6
- Dir[path_to_cops].sort.each { |cop| require cop }
6
+ Dir[path_to_cops].each { |cop| require cop }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubocop-bridgetown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bridgetown Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-11 00:00:00.000000000 Z
11
+ date: 2024-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -38,36 +38,7 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.12'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rake
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '12.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '12.0'
69
- description: A RuboCop extension to enforce common code style in Bridgetown projects
70
- and beyond
41
+ description: A RuboCop extension to enforce common code style in Bridgetown and beyond
71
42
  email:
72
43
  - maintainers@bridgetownrb.com
73
44
  executables: []
@@ -78,13 +49,14 @@ files:
78
49
  - LICENSE
79
50
  - README.md
80
51
  - lib/rubocop-bridgetown.rb
81
- - lib/rubocop/cop/bridgetown/html_escaped_heredoc.rb
52
+ - lib/rubocop/cop/bridgetown/insecure_heredoc.rb
82
53
  - lib/rubocop/cop/bridgetown/no_p_allowed.rb
83
54
  - lib/rubocop/cop/bridgetown/no_puts_allowed.rb
84
55
  homepage: https://github.com/bridgetownrb/rubocop-bridgetown
85
56
  licenses:
86
57
  - MIT
87
- metadata: {}
58
+ metadata:
59
+ rubygems_mfa_required: 'true'
88
60
  post_install_message:
89
61
  rdoc_options: []
90
62
  require_paths:
@@ -93,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
93
65
  requirements:
94
66
  - - ">="
95
67
  - !ruby/object:Gem::Version
96
- version: 2.5.0
68
+ version: 3.1.0
97
69
  required_rubygems_version: !ruby/object:Gem::Requirement
98
70
  requirements:
99
71
  - - ">="
100
72
  - !ruby/object:Gem::Version
101
73
  version: '0'
102
74
  requirements: []
103
- rubygems_version: 3.3.3
75
+ rubygems_version: 3.5.3
104
76
  signing_key:
105
77
  specification_version: 4
106
78
  summary: Code style check for Bridgetown projects