quiet_quality 1.3.0 → 1.4.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: 921a945aaedb335246c6944ae8f460505357a73d20f4f1cf2ae3dba3e9fe9041
4
- data.tar.gz: fab1f3330661738cc146e26590d489bb9fff0cc0c0318a5e9529fb9fd0802038
3
+ metadata.gz: 81e7296beb4ced635f0e6e0d1b5521adb6481b3ca4d027e86e76ad1ee8682643
4
+ data.tar.gz: 27dfab991d21f98536860a0fdbeed31faa1ea5b65a2af0941e0cc286fe6dcbc1
5
5
  SHA512:
6
- metadata.gz: 84a082f31fb8a6ae290399a97fdb5918bd91c2eaa701ec7b3909fe27e2d66845ceae7db7bcf9a59dd6696c71bfe99b4cc189f1d529bea49f5f82ba849c8fb553
7
- data.tar.gz: 222a7432405df57d2739c0799bc5844b1a916c76febf34c798891ee39e17ce79c17dedaec15928488a819261fdc35d3d746276109455cba7d490b2140c5d31c4
6
+ metadata.gz: b84bb256a178326bc76143952098db02723fcfa792ed6e86f9b6b63a0c602d87eb270d81d93e34742c2026abd7fd2118964b3a039eb8e3968863a8d1e5fe1697
7
+ data.tar.gz: 76fc65f2ce473f91a8cb98bc32c62e98ecc154aef519ab8d9e908f7def8330306b76ee2c54ed99a57bfba4b5997065b6d953747756b9a0b83e9e557c96de1d23
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## Release 1.4.0
4
+
5
+ * Support specifying `excludes` per-tool, so that certain files won't be passed
6
+ to those tools on the command-line (#107 resolves #106)
7
+
8
+ ## Release 1.3.1
9
+
10
+ * Fix a bug around the logging of nil commands when runners are skipped (#104
11
+ resolves #103)
12
+
3
13
  ## Release 1.3.0
4
14
 
5
15
  * Support (and enable by default) colorizing the console stderr output from
data/README.md CHANGED
@@ -156,14 +156,14 @@ And then each tool can have an entry, within which `changed_files` and
156
156
  `filter_messages` can be specified - the tool-specific settings override the
157
157
  global ones.
158
158
 
159
- The tools have one additional setting that is not available at a global level:
160
- `file_filter`. This is a string that will be turned into a _ruby regex_, and
161
- used to limit what file paths are passed to the tool. For example, if you are
162
- working in a rails engine `engines/foo/`, and you touch one of the rspec tests
163
- there, you would not want `qq` in the root of the repository to run
164
- `rspec engines/foo/spec/foo/thing_spec.rb` - that probably won't work, as your
165
- engine will have its own test setup code and Gemfile. This setting is mostly
166
- intended to be used like this:
159
+ The tools have two additional settings that are not available at a global level:
160
+ `file_filter` and `excludes`. `file_filter` is a string that will be turned into
161
+ a _ruby regex_, and used to limit what file paths are passed to the tool. For
162
+ example, if you are working in a rails engine `engines/foo/`, and you touch one
163
+ of the rspec tests there, you would not want `qq` in the root of the repository
164
+ to run `rspec engines/foo/spec/foo/thing_spec.rb` - that probably won't work, as
165
+ your engine will have its own test setup code and Gemfile. This setting is
166
+ mostly intended to be used like this:
167
167
 
168
168
  ```yaml
169
169
  rspec:
@@ -172,6 +172,15 @@ rspec:
172
172
  file_filter: "^spec/"
173
173
  ```
174
174
 
175
+ `excludes` are more specific in meaning - this is an _array_ of regexes, and any
176
+ file that matches any of these regexes will _not_ be passed to the tool as an
177
+ explicit command line argument. This is generally because tools like rubocop
178
+ have internal systems for excluding files, but if you pass a filename on the
179
+ cli, those systems are ignored. That means that if you have changes to a
180
+ generated file like `db/schema.rb`, and that file doesn't meet your rubocop (or
181
+ standardrb) rules, you'll get _told_ unless you exclude it at the quiet-quality
182
+ level as well.
183
+
175
184
  ### CLI Options
176
185
 
177
186
  To specify which _tools_ to run (and if any are specified, the `default_tools`
@@ -1,10 +1,14 @@
1
+ module QuietQuality
2
+ module Annotators
3
+ Unrecognized = Class.new(Error)
4
+ end
5
+ end
6
+
1
7
  glob = File.expand_path("../annotators/*.rb", __FILE__)
2
8
  Dir.glob(glob).sort.each { |f| require(f) }
3
9
 
4
10
  module QuietQuality
5
11
  module Annotators
6
- Unrecognized = Class.new(Error)
7
-
8
12
  ANNOTATOR_TYPES = {
9
13
  github_stdout: Annotators::GithubStdout
10
14
  }.freeze
@@ -0,0 +1,52 @@
1
+ module QuietQuality
2
+ module Config
3
+ class FileFilter
4
+ # * regex is a regex string
5
+ # * excludes is an array of regex strings OR a single regex string
6
+ def initialize(regex: nil, excludes: nil)
7
+ @regex_string = regex
8
+ @excludes_strings = excludes
9
+ end
10
+
11
+ def regex
12
+ return nil if @regex_string.nil?
13
+ @_regex ||= Regexp.new(@regex_string)
14
+ end
15
+
16
+ def excludes
17
+ return @_excludes if defined?(@_excludes)
18
+
19
+ @_excludes =
20
+ if @excludes_strings.nil?
21
+ nil
22
+ elsif @excludes_strings.is_a?(String)
23
+ [Regexp.new(@excludes_strings)]
24
+ else
25
+ @excludes_strings.map { |xs| Regexp.new(xs) }
26
+ end
27
+ end
28
+
29
+ # The filter _overall_ matches if:
30
+ # (a) the regex either matches or is not supplied AND
31
+ # (b) either none of the excludes match or none are supplied
32
+ def match?(s)
33
+ regex_match?(s) && !excludes_match?(s)
34
+ end
35
+
36
+ private
37
+
38
+ # The regex is an allow-match - if it's not supplied, treat everything as matching.
39
+ def regex_match?(s)
40
+ return true if regex.nil?
41
+ regex.match?(s)
42
+ end
43
+
44
+ # The excludes are a list of deny-matches - if they're not supplied, treat _nothing_
45
+ # as matching.
46
+ def excludes_match?(s)
47
+ return false if excludes.nil? || excludes.empty?
48
+ excludes.any? { |exclude| exclude.match?(s) }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -64,7 +64,7 @@ module QuietQuality
64
64
  read_tool_option(opts, tool_name, :unfiltered, :filter_messages, as: :reversed_boolean)
65
65
  read_tool_option(opts, tool_name, :changed_files, :limit_targets, as: :boolean)
66
66
  read_tool_option(opts, tool_name, :all_files, :limit_targets, as: :reversed_boolean)
67
- read_tool_option(opts, tool_name, :file_filter, :file_filter, as: :string)
67
+ read_file_filter(opts, tool_name)
68
68
  end
69
69
 
70
70
  def invalid!(message)
@@ -97,6 +97,15 @@ module QuietQuality
97
97
  opts.set_tool_option(tool, into, coerced_value)
98
98
  end
99
99
 
100
+ def read_file_filter(opts, tool)
101
+ parsed_regex = data.dig(tool.to_sym, :file_filter)
102
+ parsed_excludes = data.dig(tool.to_sym, :excludes)
103
+ if parsed_regex || parsed_excludes
104
+ filter = Config::FileFilter.new(regex: parsed_regex, excludes: parsed_excludes)
105
+ opts.set_tool_option(tool, :file_filter, filter)
106
+ end
107
+ end
108
+
100
109
  def validate_value(name, value, as:, from: nil)
101
110
  case as
102
111
  when :boolean then validate_boolean(name, value)
@@ -8,8 +8,9 @@ module QuietQuality
8
8
  @file_filter = file_filter
9
9
  end
10
10
 
11
+ attr_accessor :file_filter
11
12
  attr_reader :tool_name
12
- attr_writer :limit_targets, :filter_messages, :file_filter
13
+ attr_writer :limit_targets, :filter_messages
13
14
 
14
15
  def limit_targets?
15
16
  @limit_targets
@@ -31,17 +32,13 @@ module QuietQuality
31
32
  tool_namespace::Parser
32
33
  end
33
34
 
34
- def file_filter
35
- return nil if @file_filter.nil?
36
- Regexp.new(@file_filter)
37
- end
38
-
39
35
  def to_h
40
36
  {
41
37
  tool_name: tool_name,
42
38
  limit_targets: limit_targets?,
43
39
  filter_messages: filter_messages?,
44
- file_filter: file_filter&.to_s
40
+ file_filter: file_filter&.regex&.to_s,
41
+ excludes: file_filter&.excludes&.map(&:to_s)
45
42
  }
46
43
  end
47
44
  end
@@ -54,7 +54,8 @@ module QuietQuality
54
54
  end
55
55
 
56
56
  def log_runner(r)
57
- info("Runner #{r.tool_name} command: `#{r.command.join(" ")}`")
57
+ command_string = r.command ? "`#{r.command.join(" ")}`" : "(skipped)"
58
+ info("Runner #{r.tool_name} command: #{command_string}")
58
59
  debug("Full command for #{r.tool_name}", data: r.command)
59
60
  end
60
61
 
@@ -1,3 +1,3 @@
1
1
  module QuietQuality
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -42,4 +42,5 @@ Gem::Specification.new do |spec|
42
42
  spec.add_development_dependency "rubocop", "~> 1.50"
43
43
  spec.add_development_dependency "debug", "~> 1.7"
44
44
  spec.add_development_dependency "mdl", "~> 0.12"
45
+ spec.add_development_dependency "rspec-cover_it", "~> 0.1.0"
45
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quiet_quality
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Mueller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-06 00:00:00.000000000 Z
11
+ date: 2023-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - "~>"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0.12'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec-cover_it
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.1.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.1.0
153
167
  description: |
154
168
  Allow your CI to notice and/or annotate new quality issues, despite the presences of
155
169
  many pre-existing issues in your codebase.
@@ -189,6 +203,7 @@ files:
189
203
  - lib/quiet_quality/colorize.rb
190
204
  - lib/quiet_quality/config.rb
191
205
  - lib/quiet_quality/config/builder.rb
206
+ - lib/quiet_quality/config/file_filter.rb
192
207
  - lib/quiet_quality/config/finder.rb
193
208
  - lib/quiet_quality/config/options.rb
194
209
  - lib/quiet_quality/config/parsed_options.rb
@@ -252,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
252
267
  - !ruby/object:Gem::Version
253
268
  version: '0'
254
269
  requirements: []
255
- rubygems_version: 3.3.7
270
+ rubygems_version: 3.4.10
256
271
  signing_key:
257
272
  specification_version: 4
258
273
  summary: A system for comparing quality tool outputs against the forward diffs