quiet_quality 1.2.1 → 1.2.2

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: b3847a8d0b996b19f34c32ac587dd1b9e51a2bedbea8e777e6b888294b16b5c0
4
- data.tar.gz: 742080e4b9193d0d99606f00c68077229ffba805c5b93ffa75c09705e0101b18
3
+ metadata.gz: 6876b975446f39615f129b4fd35f3543bb998024ea292edcac1e6e1a90f7b59b
4
+ data.tar.gz: 277492ea2e6b93854e3b7d16f0184a50b5c756683929fb2a1081415e8e9836df
5
5
  SHA512:
6
- metadata.gz: b61e91968e6bdd4943809a336d60cf6a7feee9ab58db225a33f8268bd02efc911c3fa812e45491be1cc9f6d461a6db71308e790f1d912fac011c82cf4864e8d7
7
- data.tar.gz: ace3273fb13dfcd04ae2432ed0cd488195789c75a27251617fc6be851bf865e4c4b689f9c3e3e83203ffb2b1ecd2be11c258405b10a3720c186b79b5e150fe3b
6
+ metadata.gz: 7d0acaa14243573095f8741b9ca45cf56608b4ffde72f3ecd36a6ebd03cb0aeb45541ef3e4dad1c681976d5cdc3226d738a489b754d80590be032c31bbc8520b
7
+ data.tar.gz: 8e8daf77522762cca13480745f30df25cb2e445f2f7c69f98c20af9bc3b03bc8568299b8403ddbbc2e09fef750d3b3944c1a6f9b8dc2e4e22a4389a5419d05ab
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## Release 1.2.2
4
+
5
+ * Add some code to the Rspec::Parser that _cleans_ the json of certain text that
6
+ simplecov may write into the rspec json output. (#91, resolves #86)
7
+ * Include the name of the originating tool in the printed message, and the
8
+ annotation, when a warning is presented. (#90 resolves #72)
9
+ * Support `normal` as a logging level, and the `--normal` and `-n` cli
10
+ arguments. This is the default value, so this really only matters if your
11
+ config file sets another value and you want to override it from the cli.
12
+ (#91, resolves #86)
13
+
3
14
  ## Release 1.2.1
4
15
 
5
16
  * Fix the handling of the various ways to specify whether tools should limit
@@ -18,10 +18,12 @@ module QuietQuality
18
18
  # ::warning file={name},line={line},title={title}::{message}
19
19
  # See https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-a-warning-message
20
20
  def self.format(message)
21
+ title = message.tool_name.to_s
22
+ title += " #{message.rule}" if message.rule
21
23
  attributes = {
22
24
  file: message.path,
23
25
  line: message.annotated_line || message.start_line,
24
- title: message.rule
26
+ title: title
25
27
  }.compact
26
28
 
27
29
  attributes_string = attributes.map { |k, v| "#{k}=#{v}" }.join(",")
@@ -137,6 +137,10 @@ module QuietQuality
137
137
  end
138
138
 
139
139
  def setup_logging_options(parser)
140
+ parser.on("-n", "--normal", "Print outcomes and messages") do
141
+ set_global_option(:logging, Config::Logging::NORMAL)
142
+ end
143
+
140
144
  parser.on("-l", "--light", "Print aggregated results only") do
141
145
  set_global_option(:logging, Config::Logging::LIGHT)
142
146
  end
@@ -70,7 +70,7 @@ module QuietQuality
70
70
  line_range = line_range_for(msg)
71
71
  rule_string = msg.rule ? " [#{msg.rule}]" : ""
72
72
  truncated_body = reduce_text(msg.body, 120)
73
- logger.puts " #{msg.path}:#{line_range}#{rule_string} #{truncated_body}"
73
+ logger.puts "#{msg.tool_name} #{msg.path}:#{line_range}#{rule_string} #{truncated_body}"
74
74
  end
75
75
  end
76
76
  end
@@ -3,11 +3,12 @@ module QuietQuality
3
3
  class Logging
4
4
  LIGHT = :light
5
5
  QUIET = :quiet
6
- LEVELS = [LIGHT, QUIET].freeze
6
+ NORMAL = :normal
7
+ LEVELS = [LIGHT, QUIET, NORMAL].freeze
7
8
 
8
9
  attr_accessor :level
9
10
 
10
- def initialize(level: nil)
11
+ def initialize(level: NORMAL)
11
12
  @level = level
12
13
  end
13
14
 
@@ -1,7 +1,8 @@
1
1
  module QuietQuality
2
2
  class Message
3
- attr_accessor :annotated_line
4
- attr_reader :path, :body, :start_line, :stop_line, :level, :rule
3
+ REQUIRED_ATTRS = %w[path body start_line tool_name].freeze
4
+
5
+ attr_writer :annotated_line
5
6
 
6
7
  def self.load(hash)
7
8
  new(**hash)
@@ -9,17 +10,51 @@ module QuietQuality
9
10
 
10
11
  def initialize(**attrs)
11
12
  @attrs = attrs.map { |k, v| [k.to_s, v] }.to_h
12
- @path = @attrs.fetch("path")
13
- @body = @attrs.fetch("body")
14
- @start_line = @attrs.fetch("start_line")
15
- @stop_line = @attrs.fetch("stop_line", @start_line)
16
- @annotated_line = @attrs.fetch("annotated_line", nil)
17
- @level = @attrs.fetch("level", nil)
18
- @rule = @attrs.fetch("rule", nil)
13
+ validate_attrs!
19
14
  end
20
15
 
21
16
  def to_h
22
17
  @attrs.map { |k, v| [k.to_s, v] }.to_h
23
18
  end
19
+
20
+ def path
21
+ @_path ||= @attrs.fetch("path")
22
+ end
23
+
24
+ def body
25
+ @_body ||= @attrs.fetch("body")
26
+ end
27
+
28
+ def tool_name
29
+ @_tool_name ||= @attrs.fetch("tool_name")
30
+ end
31
+
32
+ def start_line
33
+ @_start_line ||= @attrs.fetch("start_line")
34
+ end
35
+
36
+ def stop_line
37
+ @_stop_line ||= @attrs.fetch("stop_line", start_line)
38
+ end
39
+
40
+ def annotated_line
41
+ @annotated_line ||= @attrs.fetch("annotated_line", nil)
42
+ end
43
+
44
+ def level
45
+ @_level ||= @attrs.fetch("level", nil)
46
+ end
47
+
48
+ def rule
49
+ @_rule ||= @attrs.fetch("rule", nil)
50
+ end
51
+
52
+ private
53
+
54
+ def validate_attrs!
55
+ REQUIRED_ATTRS.each do |attr|
56
+ raise ArgumentError, "Missing required attribute #{attr}" unless @attrs[attr]
57
+ end
58
+ end
24
59
  end
25
60
  end
@@ -37,7 +37,14 @@ module QuietQuality
37
37
  line = warning.fetch(:line)
38
38
  level = warning.fetch(:confidence, nil)
39
39
  rule = warning.fetch(:warning_type)
40
- Message.new(path: path, body: body, start_line: line, level: level, rule: rule)
40
+ Message.new(
41
+ path: path,
42
+ body: body,
43
+ start_line: line,
44
+ level: level,
45
+ rule: rule,
46
+ tool_name: TOOL_NAME
47
+ )
41
48
  end
42
49
  end
43
50
  end
@@ -3,7 +3,7 @@ module QuietQuality
3
3
  module Brakeman
4
4
  class Runner < BaseRunner
5
5
  def tool_name
6
- :brakeman
6
+ TOOL_NAME
7
7
  end
8
8
 
9
9
  def command
@@ -3,6 +3,7 @@ require_relative "./rubocop"
3
3
  module QuietQuality
4
4
  module Tools
5
5
  module Brakeman
6
+ TOOL_NAME = :brakeman
6
7
  end
7
8
  end
8
9
  end
@@ -36,7 +36,8 @@ module QuietQuality
36
36
  body: offense.fetch(:message),
37
37
  start_line: offense.dig(:location, :line),
38
38
  level: offense.fetch(:severity, nil),
39
- rule: offense.fetch(:linter_name, nil)
39
+ rule: offense.fetch(:linter_name, nil),
40
+ tool_name: TOOL_NAME
40
41
  )
41
42
  end
42
43
  end
@@ -3,7 +3,7 @@ module QuietQuality
3
3
  module HamlLint
4
4
  class Runner < RelevantRunner
5
5
  def tool_name
6
- :haml_lint
6
+ TOOL_NAME
7
7
  end
8
8
 
9
9
  def no_files_output
@@ -1,6 +1,7 @@
1
1
  module QuietQuality
2
2
  module Tools
3
3
  module HamlLint
4
+ TOOL_NAME = :haml_lint
4
5
  end
5
6
  end
6
7
  end
@@ -25,7 +25,8 @@ module QuietQuality
25
25
  path: entry.fetch(:filename),
26
26
  start_line: entry.fetch(:line),
27
27
  rule: entry.fetch(:description),
28
- body: entry.fetch(:docs)
28
+ body: entry.fetch(:docs),
29
+ tool_name: TOOL_NAME
29
30
  )
30
31
  end
31
32
  end
@@ -3,7 +3,7 @@ module QuietQuality
3
3
  module MarkdownLint
4
4
  class Runner < RelevantRunner
5
5
  def tool_name
6
- :markdown_lint
6
+ TOOL_NAME
7
7
  end
8
8
 
9
9
  def no_files_output
@@ -1,6 +1,7 @@
1
1
  module QuietQuality
2
2
  module Tools
3
3
  module MarkdownLint
4
+ TOOL_NAME = :markdown_lint
4
5
  end
5
6
  end
6
7
  end
@@ -16,8 +16,26 @@ module QuietQuality
16
16
 
17
17
  attr_reader :text
18
18
 
19
+ # Many people use simplecov with rspec, and its default formatter
20
+ # writes text output into the stdout stream of rspec even when rspec is
21
+ # asked for json output. I have an issue open here, and I'll get a pair
22
+ # of PRs together if they indicate any willingness to accept such a
23
+ # change: https://github.com/simplecov-ruby/simplecov/issues/1060
24
+ #
25
+ # The only stdout writes are visible on these lines:
26
+ # https://github.com/simplecov-ruby/simplecov-html/blob/main/lib/simplecov-html.rb#L31
27
+ # https://github.com/simplecov-ruby/simplecov-html/blob/main/lib/simplecov-html.rb#L80
28
+ #
29
+ # There are _hundreds_ of rspec plugins, and any of them could write to
30
+ # stdout - we probably won't worry about any but the most common.
31
+ def cleaned_text
32
+ @_cleaned_text ||= text
33
+ .gsub(/Coverage report generated.*covered.$/, "")
34
+ .gsub(/Encoding problems with file.*$/, "")
35
+ end
36
+
19
37
  def content
20
- @_content ||= JSON.parse(text, symbolize_names: true)
38
+ @_content ||= JSON.parse(cleaned_text, symbolize_names: true)
21
39
  end
22
40
 
23
41
  def examples
@@ -37,7 +55,13 @@ module QuietQuality
37
55
  body = example.dig(:exception, :message) || example.fetch(:description)
38
56
  line = example.fetch(:line_number)
39
57
  rule = example.dig(:exception, :class) || "Failed Example"
40
- Message.new(path: path, body: body, start_line: line, rule: rule)
58
+ Message.new(
59
+ path: path,
60
+ body: body,
61
+ start_line: line,
62
+ rule: rule,
63
+ tool_name: TOOL_NAME
64
+ )
41
65
  end
42
66
  end
43
67
  end
@@ -3,7 +3,7 @@ module QuietQuality
3
3
  module Rspec
4
4
  class Runner < RelevantRunner
5
5
  def tool_name
6
- :rspec
6
+ TOOL_NAME
7
7
  end
8
8
 
9
9
  def no_files_output
@@ -1,6 +1,7 @@
1
1
  module QuietQuality
2
2
  module Tools
3
3
  module Rspec
4
+ TOOL_NAME = :rspec
4
5
  end
5
6
  end
6
7
  end
@@ -37,9 +37,14 @@ module QuietQuality
37
37
  start_line: offense.dig(:location, :start_line),
38
38
  stop_line: offense.dig(:location, :last_line),
39
39
  level: offense.fetch(:severity, nil),
40
- rule: offense.fetch(:cop_name, nil)
40
+ rule: offense.fetch(:cop_name, nil),
41
+ tool_name: tool_name
41
42
  )
42
43
  end
44
+
45
+ def tool_name
46
+ TOOL_NAME
47
+ end
43
48
  end
44
49
  end
45
50
  end
@@ -3,7 +3,7 @@ module QuietQuality
3
3
  module Rubocop
4
4
  class Runner < RelevantRunner
5
5
  def tool_name
6
- :rubocop
6
+ TOOL_NAME
7
7
  end
8
8
 
9
9
  def no_files_output
@@ -1,6 +1,7 @@
1
1
  module QuietQuality
2
2
  module Tools
3
3
  module Rubocop
4
+ TOOL_NAME = :rubocop
4
5
  end
5
6
  end
6
7
  end
@@ -2,6 +2,9 @@ module QuietQuality
2
2
  module Tools
3
3
  module Standardrb
4
4
  class Parser < Rubocop::Parser
5
+ def tool_name
6
+ TOOL_NAME
7
+ end
5
8
  end
6
9
  end
7
10
  end
@@ -3,7 +3,7 @@ module QuietQuality
3
3
  module Standardrb
4
4
  class Runner < RelevantRunner
5
5
  def tool_name
6
- :standardrb
6
+ TOOL_NAME
7
7
  end
8
8
 
9
9
  def no_files_output
@@ -3,6 +3,7 @@ require_relative "./rubocop"
3
3
  module QuietQuality
4
4
  module Tools
5
5
  module Standardrb
6
+ TOOL_NAME = :standardrb
6
7
  end
7
8
  end
8
9
  end
@@ -1,3 +1,3 @@
1
1
  module QuietQuality
2
- VERSION = "1.2.1"
2
+ VERSION = "1.2.2"
3
3
  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.2.1
4
+ version: 1.2.2
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-03 00:00:00.000000000 Z
11
+ date: 2023-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git