immosquare-cleaner 1.0.1 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7665690ab0d77f314f9feaa5a957d405e6180b886bc6ec0f8489984e4bb32b96
4
- data.tar.gz: f8879a8bdbf932fd97f984ecac4a22b36e7ba223b6db7ef1f0f213375c34d785
3
+ metadata.gz: 7165a24bce4d5074d6c51081764a2689116e996bafa14ed85ddc1fc43ea50e29
4
+ data.tar.gz: a8b504859e4cfe9f9f1ecf552a058fad07a773b54639630601feee28c5038aeb
5
5
  SHA512:
6
- metadata.gz: 952cac84543b75a8bf42cd2adf738bd702e2d0c424b069103aedc9145b522f10ad8aa5883e03b9532b6232ff605213f3e4c1bc781420fc35b5b21da693723cb0
7
- data.tar.gz: 761039c215cf757e82f24b02e302dac4195f22a2233d336e94940d71ca2345eaea72c305bd3a8ace4658441f7bf3e9615bef7da2a1614c8050661b3ea989607a
6
+ metadata.gz: b6dbd75516dc30b9cecc8c6400597ec6b75c99a70882c9d2bc18523b7dada2d670ecd20287c4de7cdd6e0ad2a2949c64254f6a37b2856ca2cfa434427008809b
7
+ data.tar.gz: 69c695dc0204e4ef7a7ebfeaec6d1fcad0f5ba8adb8622d33dfc983a31b1453c8c668d149f31dfc344a17083a12c052bffa608c8d4dbd39b3545a6fc3d631f81
@@ -1,3 +1,3 @@
1
1
  module ImmosquareCleaner
2
- VERSION = "1.0.1".freeze
2
+ VERSION = "1.0.2".freeze
3
3
  end
@@ -74,7 +74,7 @@ module ERBLint
74
74
  context = {
75
75
  :new_code => "<%= #{new_code} %>",
76
76
  :output_node => output_node,
77
- :is_output_node => is_output_erb?(output_node)
77
+ :is_output_node => output_erb?(output_node)
78
78
  }
79
79
 
80
80
  add_offense(full_range, MSG, context)
@@ -102,9 +102,9 @@ module ERBLint
102
102
  ## output_node should be <%= (output)
103
103
  ## end_node should be <% (not <%=)
104
104
  ##============================================================##
105
- return false unless is_statement_erb?(if_node)
106
- return false unless is_output_erb?(output_node)
107
- return false unless is_statement_erb?(end_node)
105
+ return false unless statement_erb?(if_node)
106
+ return false unless output_erb?(output_node)
107
+ return false unless statement_erb?(end_node)
108
108
 
109
109
  ##============================================================##
110
110
  ## Extract and validate the code
@@ -133,7 +133,7 @@ module ERBLint
133
133
  ##============================================================##
134
134
  ## Check if ERB node is a statement (<% ... %>)
135
135
  ##============================================================##
136
- def is_statement_erb?(erb_node)
136
+ def statement_erb?(erb_node)
137
137
  indicator = erb_node.children.first
138
138
  indicator.nil? || (indicator.respond_to?(:children) && indicator.children.first.nil?)
139
139
  end
@@ -141,7 +141,7 @@ module ERBLint
141
141
  ##============================================================##
142
142
  ## Check if ERB node is an output (<%= ... %>)
143
143
  ##============================================================##
144
- def is_output_erb?(erb_node)
144
+ def output_erb?(erb_node)
145
145
  indicator = erb_node.children.first
146
146
  indicator.respond_to?(:children) && indicator.children.first == "="
147
147
  end
@@ -104,16 +104,13 @@ module RuboCop
104
104
  in_code = !in_code
105
105
  body << text
106
106
  content_seen = true
107
- elsif in_code || text.match?(RAW_LINE)
107
+ elsif verbatim_line?(text, in_code)
108
108
  body << text
109
109
  content_seen = true
110
110
  elsif text == BLANK_LINE
111
111
  body << BLANK_LINE if content_seen
112
112
  elsif text.match?(USER_SEPARATOR)
113
113
  body << INSIDE_SEPARATOR if content_seen
114
- elsif text.match?(STRUCTURED_LINE) || text.match?(INDENTED_LINE)
115
- body << text
116
- content_seen = true
117
114
  else
118
115
  body << cleaned_line(text)
119
116
  content_seen = true
@@ -123,6 +120,20 @@ module RuboCop
123
120
  body
124
121
  end
125
122
 
123
+ ##============================================================##
124
+ ## Lines kept as written. Precedence matters: inside a code
125
+ ## block or on a raw line everything is verbatim, even "##" or
126
+ ## a separator; elsewhere a blank line and a user separator win
127
+ ## over the structured/indented patterns ("## ---" is a
128
+ ## separator, not an indented line).
129
+ ##============================================================##
130
+ def verbatim_line?(text, in_code)
131
+ return true if in_code || text.match?(RAW_LINE)
132
+ return false if text == BLANK_LINE || text.match?(USER_SEPARATOR)
133
+
134
+ text.match?(STRUCTURED_LINE) || text.match?(INDENTED_LINE)
135
+ end
136
+
126
137
  ##============================================================##
127
138
  ## Cleans up a standard text line:
128
139
  ## - "### foo" → "## foo" (collapse repeated #)
@@ -32,6 +32,14 @@ Naming/FileName:
32
32
  Enabled: false
33
33
  Naming/MethodParameterName:
34
34
  MinNameLength: 1
35
+ Naming/PredicateMethod:
36
+ AllowedMethods:
37
+ - call
38
+ - move_to_cache
39
+ - move_to_store
40
+ - save
41
+ - check_health
42
+ - elastic_import_with_progressbar
35
43
  Layout/LeadingEmptyLines:
36
44
  Enabled: false
37
45
  Layout/InitialIndentation:
@@ -88,6 +96,11 @@ Style/NegatedIf:
88
96
  Enabled: false
89
97
  Style/FormatStringToken:
90
98
  EnforcedStyle: template
99
+ Mode: conservative
100
+ Style/OptionalBooleanParameter:
101
+ AllowedMethods:
102
+ - respond_to_missing?
103
+ - perform
91
104
  Style/NumericPredicate:
92
105
  EnforcedStyle: comparison
93
106
  Style/StringLiterals:
data/linters/rubocop.yml CHANGED
@@ -37,6 +37,14 @@ Naming/FileName:
37
37
  Enabled: false # Allow filenames with dashes (e.g. immosquare-cleaner.rb)
38
38
  Naming/MethodParameterName:
39
39
  MinNameLength: 1 # Allow single-character parameter names
40
+ Naming/PredicateMethod:
41
+ AllowedMethods:
42
+ - call
43
+ - move_to_cache # CarrierWave hooks: the gem calls them by these names and reads their boolean return.
44
+ - move_to_store
45
+ - save # ActiveModel contract: form objects expose `save` returning true/false, like ActiveRecord.
46
+ - check_health # Commands returning their success status (immosquare-railtie PumaManager, Elasticsearch import): a `?` name would hide the side effects.
47
+ - elastic_import_with_progressbar
40
48
 
41
49
  #################### Layout ###########################
42
50
  Layout/LeadingEmptyLines:
@@ -98,6 +106,11 @@ Style/NegatedIf:
98
106
  Enabled: false # Allow rewriting `if !` as `unless`
99
107
  Style/FormatStringToken:
100
108
  EnforcedStyle: "template" ## Use %{my_string} interpolation, not %<my_string>s
109
+ Mode: conservative # Only strings passed to format/sprintf/%. In aggressive mode any literal containing `%<x>s` is flagged, including prose that lists placeholders (e.g. an AI prompt telling the model which tokens to preserve), where rewriting the token changes the text.
110
+ Style/OptionalBooleanParameter:
111
+ AllowedMethods:
112
+ - respond_to_missing?
113
+ - perform # Sidekiq and ActiveJob serialize `perform` arguments as JSON: keyword arguments are not reliably supported, and jobs already enqueued keep their positional shape.
101
114
  Style/NumericPredicate:
102
115
  EnforcedStyle: comparison # No `.zero?` `.negative?` `.positive?`
103
116
  Style/StringLiterals:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: immosquare-cleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - immosquare