rubocop-bridgetown 0.4.1 → 0.5.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: 55ea7b4b8b72d1401042de211382cae15ca378f6bcc70cd0d285de5a04db69e9
4
+ data.tar.gz: ba2a83d81067a2bf70c1c5b9477471b0127858ff44d1748be926149ed1dd98a6
5
5
  SHA512:
6
- metadata.gz: '094a43e9ab0e00667fe83e775bf9bc85a487df3308bcdc1692dbded1c3fe94599c9a278f0d6a283e4a4cc8da7db7af0fe2e1a688196b3816071b777330400ac9'
7
- data.tar.gz: 2870d7b4a58f7ab628978dcc3ed4e4ecebb1f37ca0e003e670d69764fd61ba3161224234e9312c5c1527b20226723fee958fa65609c084b422aaecb86abf1186
6
+ metadata.gz: cd922c7f02e8f8f4ef9ef46d5ae1252c62dbf69df305638856870dc17aba727c0bcbcfc24bf6995c0e1f1a98ace36cf1ccfadeb4c4dd11f5e76b7c7b356c564f
7
+ data.tar.gz: 96beab10089b0ab81d2381e75080ab4e650eca57b86486aa61be69bfb839bb454da7bce1b2d3b77be47321ca3d5386a84062f94c88bd19d40f9e829189878fed
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:
@@ -78,7 +80,7 @@ Style/ModuleFunction:
78
80
  Style/MultilineBlockChain:
79
81
  Enabled: false
80
82
  Style/MultilineTernaryOperator:
81
- Severity: error
83
+ Enabled: false
82
84
  Style/ParallelAssignment:
83
85
  Enabled: false
84
86
  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 < Cop
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,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.5.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-04-11 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