cleo_quality_review 0.2.0 → 0.3.0
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 +4 -4
- data/cleo_quality_review.gemspec +0 -1
- data/lib/cleo_quality_review/checks.rb +0 -1
- data/lib/cleo_quality_review/options.rb +2 -2
- data/lib/cleo_quality_review/version.rb +1 -1
- data/lib/cleo_quality_review.rb +0 -1
- data/prompts/agent.md +2 -3
- data/prompts/github.md +0 -4
- data/prompts/human.md +3 -4
- data/prompts/pr_review.md +1 -2
- metadata +1 -16
- data/lib/cleo_quality_review/checks/debride.rb +0 -65
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2f7c748370590a154e611c6302e8bbfd9e5c3f8dc1b756e938ccba09101b6ee5
|
|
4
|
+
data.tar.gz: 85e837b45af4b31c23e9f59d613653a481a5e172da0581df8edc96945c4f409c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7f5f53a18a2cd9ef9e6e7c3456b416d4b2f0dcab0d36d3c4d75e70c1c97bb408659918c89d57ab284faf05e7111cd06f0fc39f34f1be0d08f611f48945fe9ace
|
|
7
|
+
data.tar.gz: dabda2763af548f1ef2be712d6b3a0ec8ca1ca03330a249ea91b35972176a3f37785677dd39334ff207aae8374d586358a0c1c3a1a402f0e9ac94ab1c4dadff5
|
data/cleo_quality_review.gemspec
CHANGED
|
@@ -120,7 +120,7 @@ module CleoQualityReview
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
def register_checks_option(opts)
|
|
123
|
-
opts.on("-c", "--checks CHECKS", Array, "Checks to run: all, reek, flog, fasterer
|
|
123
|
+
opts.on("-c", "--checks CHECKS", Array, "Checks to run: all, reek, flog, fasterer") { |values| checks.concat(values) }
|
|
124
124
|
end
|
|
125
125
|
|
|
126
126
|
def register_only_option(opts)
|
|
@@ -128,7 +128,7 @@ module CleoQualityReview
|
|
|
128
128
|
end
|
|
129
129
|
|
|
130
130
|
def register_exclude_option(opts)
|
|
131
|
-
opts.on("-x", "--exclude CHECKS", Array, "Checks to exclude: reek, flog, fasterer
|
|
131
|
+
opts.on("-x", "--exclude CHECKS", Array, "Checks to exclude: reek, flog, fasterer") { |values| exclude.concat(values) }
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
def register_target_options(opts)
|
data/lib/cleo_quality_review.rb
CHANGED
|
@@ -14,7 +14,6 @@ module CleoQualityReview
|
|
|
14
14
|
Checks.register("Reek", Checks::Reek, tool_type: :smell_detection)
|
|
15
15
|
Checks.register("Flog", Checks::Flog, tool_type: :complexity)
|
|
16
16
|
Checks.register("Fasterer", Checks::Fasterer, tool_type: :performance)
|
|
17
|
-
Checks.register("Debride", Checks::Debride, tool_type: :dead_code)
|
|
18
17
|
|
|
19
18
|
##
|
|
20
19
|
# Register all supported LLM APIs for formatting output here
|
data/prompts/agent.md
CHANGED
|
@@ -7,7 +7,6 @@ Analyze the raw tool outputs and git diff provided. Prioritize actionable issues
|
|
|
7
7
|
- **Flog**: Ignore scores below 40.0
|
|
8
8
|
- **Reek**: Focus on FeatureEnvy, TooManyStatements, DuplicateMethodCall, NestedIterators, LongParameterList
|
|
9
9
|
- **Fasterer**: Include all performance suggestions
|
|
10
|
-
- **Debride**: Treat as lower-confidence static dead-code detection. Include only findings that are clearly actionable and avoid recommending deletion without checking dynamic call paths.
|
|
11
10
|
|
|
12
11
|
## Output Format
|
|
13
12
|
|
|
@@ -21,7 +20,7 @@ Output valid JSON matching this exact schema:
|
|
|
21
20
|
"target_files": [<file paths from metadata>],
|
|
22
21
|
"findings": [
|
|
23
22
|
{
|
|
24
|
-
"tool_name": "<reek|flog|fasterer
|
|
23
|
+
"tool_name": "<reek|flog|fasterer>",
|
|
25
24
|
"tool_type": "<smell_detection|complexity|performance|dead_code>",
|
|
26
25
|
"check": "<specific check type>",
|
|
27
26
|
"filepath": "<relative file path>",
|
|
@@ -33,7 +32,7 @@ Output valid JSON matching this exact schema:
|
|
|
33
32
|
"check_outputs": [
|
|
34
33
|
{
|
|
35
34
|
"check_name": "<check name>",
|
|
36
|
-
"tool_name": "<reek|flog|fasterer
|
|
35
|
+
"tool_name": "<reek|flog|fasterer>",
|
|
37
36
|
"tool_type": "<smell_detection|complexity|performance|dead_code>",
|
|
38
37
|
"extension": "<json|txt>",
|
|
39
38
|
"path": "<raw output artifact path>",
|
data/prompts/github.md
CHANGED
|
@@ -17,10 +17,6 @@ Reek:
|
|
|
17
17
|
Fasterer:
|
|
18
18
|
Severity: Low
|
|
19
19
|
|
|
20
|
-
Debride:
|
|
21
|
-
Severity: Low
|
|
22
|
-
Notes: Lower-confidence static dead-code signal. Only report when the finding is specific, actionable, and unlikely to be a dynamic Rails call.
|
|
23
|
-
|
|
24
20
|
|
|
25
21
|
You MUST NOT return so many items that the feedback is noisy and confusing. Limit yourself to maximum 10 comments.
|
|
26
22
|
|
data/prompts/human.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
You are reviewing a local code change for code quality.
|
|
2
2
|
|
|
3
|
-
The files provided include git diffs for local code changes, as well as generated output files from various code quality assessment tools including (but not limited to) Reek, Flog, Fasterer,
|
|
3
|
+
The files provided include git diffs for local code changes, as well as generated output files from various code quality assessment tools including (but not limited to) Reek, Flog, Fasterer, etc.
|
|
4
4
|
|
|
5
5
|
Your task is to parse the static output files generated by these tools, and provide feedback to the human user. The diff provided is to allow you to map tool output to changes in the code.
|
|
6
6
|
|
|
7
|
-
YOU MUST NOT comment on the code diff itself, unless the comment is in
|
|
7
|
+
YOU MUST NOT comment on the code diff itself, unless the comment is in relation to an issue reported by a tool.
|
|
8
8
|
|
|
9
9
|
Prioritize issues that are likely to matter to maintainability, correctness, readability, or long-term ownership.
|
|
10
10
|
|
|
@@ -12,9 +12,8 @@ Avoid repeating tool output mechanically. If multiple issues of the same sort ar
|
|
|
12
12
|
|
|
13
13
|
If a tool finding is low value or likely a false positive, say so briefly or omit it.
|
|
14
14
|
|
|
15
|
-
Debride findings are lower-confidence static dead-code candidates. Do not recommend deleting code unless the finding is clearly supported by the changed code and dynamic call paths have been considered.
|
|
16
15
|
|
|
17
|
-
The output will be printed in a
|
|
16
|
+
The output will be printed in a Unix terminal, and so colour-coded feedback is preferable.
|
|
18
17
|
|
|
19
18
|
1. Highest-impact issues first, with file and line references as clickable links when available.
|
|
20
19
|
2. Suggested changes that are specific enough for an engineer or coding agent to implement.
|
data/prompts/pr_review.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
You are the pipeline interface between code quality tools and GitHub pull request review comments.
|
|
2
2
|
|
|
3
|
-
You will collate data from code quality tools including Reek, Flog,
|
|
3
|
+
You will collate data from code quality tools including Reek, Flog, and Fasterer. The raw output is noisy, so your job is to identify only the most useful comments for the engineer whose PR triggered this flow.
|
|
4
4
|
|
|
5
5
|
You MUST NOT comment on the code diff itself unless the comment is directly supported by a tool finding.
|
|
6
6
|
|
|
@@ -9,7 +9,6 @@ You MUST NOT comment on the code diff itself unless the comment is directly supp
|
|
|
9
9
|
- **Flog**: Ignore scores below 40.0. Prioritize high-complexity methods because they are the most expensive to maintain.
|
|
10
10
|
- **Reek**: Prefer actionable smells such as FeatureEnvy, TooManyStatements, DuplicateMethodCall, NestedIterators, and LongParameterList.
|
|
11
11
|
- **Fasterer**: Low severity. Include only when the finding is clearly on code changed by this PR and the fix is straightforward.
|
|
12
|
-
- **Debride**: Lower-confidence static dead-code signal. Include only when the candidate method is clearly made obsolete by this PR, and do not suggest deletion without noting possible dynamic Rails calls.
|
|
13
12
|
|
|
14
13
|
## Comment Selection
|
|
15
14
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cleo_quality_review
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Gavin Morrice
|
|
@@ -9,20 +9,6 @@ bindir: exe
|
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
name: debride
|
|
14
|
-
requirement: !ruby/object:Gem::Requirement
|
|
15
|
-
requirements:
|
|
16
|
-
- - ">="
|
|
17
|
-
- !ruby/object:Gem::Version
|
|
18
|
-
version: '0'
|
|
19
|
-
type: :runtime
|
|
20
|
-
prerelease: false
|
|
21
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
-
requirements:
|
|
23
|
-
- - ">="
|
|
24
|
-
- !ruby/object:Gem::Version
|
|
25
|
-
version: '0'
|
|
26
12
|
- !ruby/object:Gem::Dependency
|
|
27
13
|
name: fasterer
|
|
28
14
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -80,7 +66,6 @@ files:
|
|
|
80
66
|
- lib/cleo_quality_review.rb
|
|
81
67
|
- lib/cleo_quality_review/changes_diff.rb
|
|
82
68
|
- lib/cleo_quality_review/checks.rb
|
|
83
|
-
- lib/cleo_quality_review/checks/debride.rb
|
|
84
69
|
- lib/cleo_quality_review/checks/fasterer.rb
|
|
85
70
|
- lib/cleo_quality_review/checks/flog.rb
|
|
86
71
|
- lib/cleo_quality_review/checks/quality_check.rb
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "json"
|
|
4
|
-
|
|
5
|
-
require_relative "quality_check"
|
|
6
|
-
|
|
7
|
-
module CleoQualityReview
|
|
8
|
-
module Checks
|
|
9
|
-
##
|
|
10
|
-
# Quality check implementation for Debride unused-code analyzer
|
|
11
|
-
class Debride < QualityCheck
|
|
12
|
-
self.check_name = "dead_code"
|
|
13
|
-
self.tool_name = "debride"
|
|
14
|
-
self.output_extension = "json"
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
def command(files)
|
|
19
|
-
[ruby_executable, gem_executable("debride", "debride"), "--json", "--rails", *files]
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def parse(stdout, stderr)
|
|
23
|
-
findings = missing_methods(stdout).flat_map do |class_name, methods|
|
|
24
|
-
results_for_class(class_name, methods)
|
|
25
|
-
end
|
|
26
|
-
return findings unless findings.empty? && stderr.to_s.strip != ""
|
|
27
|
-
|
|
28
|
-
[result(check: "Execution error", message: stderr, filepath: nil)]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
def missing_methods(stdout)
|
|
32
|
-
parsed = JSON.parse(stdout.to_s)
|
|
33
|
-
missing = parsed.fetch("missing", {})
|
|
34
|
-
return {} unless missing.is_a?(Hash)
|
|
35
|
-
|
|
36
|
-
missing
|
|
37
|
-
rescue JSON::ParserError
|
|
38
|
-
{}
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def results_for_class(class_name, methods)
|
|
42
|
-
Array(methods).map { |entry| method_to_result(class_name, entry) }
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def method_to_result(class_name, entry)
|
|
46
|
-
method_name, location = Array(entry)
|
|
47
|
-
filepath, line = parse_location(location)
|
|
48
|
-
|
|
49
|
-
result(
|
|
50
|
-
check: "PotentialDeadMethod",
|
|
51
|
-
message: "#{class_name}##{method_name} might not be called",
|
|
52
|
-
filepath: filepath,
|
|
53
|
-
line: line,
|
|
54
|
-
)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def parse_location(location)
|
|
58
|
-
match = location.to_s.match(/\A(?<filepath>.*):(?<line>\d+)(?:-\d+)?\z/)
|
|
59
|
-
return [nil, nil] unless match
|
|
60
|
-
|
|
61
|
-
match.values_at(:filepath, :line)
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|