crap4ruby 0.2.0 → 0.2.1

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: e5227286a59e47edaf5fe8e20c8ce9c1abe6391b4f95304f8352c6b98fdf53dd
4
- data.tar.gz: 2a569cea7aa8f9172d2ce2c854dec0d62c76ae3e73f1f3618f911b3d55c6deff
3
+ metadata.gz: b2e848e88bdf6cd4f6b2f0a5477aa3a9f3565651006864d7101ad13beab82c7c
4
+ data.tar.gz: cc9a67ce5aaea92c6d7311f00526900017df5904c157d16764b77cbd27a0a9e7
5
5
  SHA512:
6
- metadata.gz: 25f98c5d9ca08faa51388483dc63735238f4dc0a20daf13a80ad104086e48c36d91fb2204a2d4e25a903ce17ccdd510cb8059be09b47ea4a582921fee1a5b649
7
- data.tar.gz: b819b05ff07ec266c2316f77b317b2f45975e4ebd7ed2e4f325aea8553a2fa767033d4351086ab67979f9230523497f1d91aab3f49fad540ae911c529fd4dbce
6
+ metadata.gz: 546293a428b456b48c4c22b34fe09980a2c88f1c7af0d69f8aa24f598fa5441993e8c50f1dc29dc346c233e0a8ffada8106fc13894a15a6185b1877c9823840a
7
+ data.tar.gz: ed047a7174bcce565ff2b248729f4faa61208f8a20794a6903d0fe9cfca7e1381243bd12287502dd5cfdef1087153c0720b363e098e39e32364262ade1501ddf
data/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ Version numbers follow [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.2.1] - 2026-10-29
9
+
10
+ ### Added
11
+
12
+ - Add `--no-save` to print results and check thresholds without creating or replacing `.metrics/crap.edn`.
13
+
8
14
  ## [0.2.0] - 2026-10-28
9
15
 
10
16
  ### Changed
@@ -42,7 +48,8 @@ Version numbers follow [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.
42
48
 
43
49
  - Split CLI execution, AST discovery, and coverage loading into smaller methods without changing their behavior or scoring rules.
44
50
 
45
- [Unreleased]: https://github.com/svyatov/crap4ruby/compare/v0.2.0...HEAD
51
+ [Unreleased]: https://github.com/svyatov/crap4ruby/compare/v0.2.1...HEAD
52
+ [0.2.1]: https://github.com/svyatov/crap4ruby/compare/v0.2.0...v0.2.1
46
53
  [0.2.0]: https://github.com/svyatov/crap4ruby/compare/v0.1.1...v0.2.0
47
54
  [0.1.1]: https://github.com/svyatov/crap4ruby/compare/v0.1.0...v0.1.1
48
55
  [0.1.0]: https://github.com/svyatov/crap4ruby/releases/tag/v0.1.0
data/README.md CHANGED
@@ -46,7 +46,7 @@ Run these commands from this checkout with Ruby 3.3 or newer:
46
46
  ```sh
47
47
  bundle install
48
48
  gem build crap4ruby.gemspec
49
- gem install ./crap4ruby-0.2.0.gem
49
+ gem install ./crap4ruby-0.2.1.gem
50
50
  ```
51
51
 
52
52
  To use Bundler in the measured project, add this checkout to that project's `Gemfile`:
@@ -96,6 +96,7 @@ crap4ruby does not configure SimpleCov, delete reports, install dependencies, or
96
96
  | `--use-existing-coverage` | Explicitly select the default: read reports without running tests. |
97
97
  | `--coverage-command COMMAND` | Run a shell command that refreshes the selected report. |
98
98
  | `--no-coverage` | Report complexity with unknown coverage and CRAP. |
99
+ | `--no-save` | Print results without creating or replacing `.metrics/crap.edn`. |
99
100
  | `--threshold NUMBER` | Check this finite, nonnegative limit; exit 2 for a measured violation, or 1 if an unknown score could exceed it. |
100
101
  | `-h`, `--help` | Print usage. |
101
102
  | `-v`, `--version` | Print the gem version. |
@@ -114,7 +115,16 @@ Exit 2 means a measured score exceeded the threshold. A measured violation takes
114
115
  Decimal thresholds are compared exactly with the computed scores, before display rounding.
115
116
  For unknown scores, the check uses the maximum possible score, `CC^2 + CC`, at zero coverage. If this maximum fits the threshold, the method passes; otherwise, the check returns exit 1 and names the method. Its displayed score remains N/A. This also applies with `--no-coverage`.
116
117
  For example, an unknown score at CC 2 passes a threshold of 6, but cannot pass a threshold of 5. Supply fresh, measurable coverage or adjust the limit to resolve uncertainty.
117
- Every completed analysis replaces the snapshot, including filtered analyses, empty selections, and failed threshold checks.
118
+ By default, every completed analysis replaces the snapshot, including filtered analyses, empty selections, and failed threshold checks.
119
+
120
+ For pre-commit or pre-push hooks that check complexity without tests or coverage, use:
121
+
122
+ ```sh
123
+ bundle exec crap4ruby --no-coverage --no-save
124
+ ```
125
+
126
+ `--no-save` preserves the terminal report and threshold exit codes while leaving the snapshot unchanged.
127
+ It also works with coverage enabled.
118
128
 
119
129
  ## Complexity and coverage
120
130
 
data/lib/crap4ruby/cli.rb CHANGED
@@ -14,7 +14,7 @@ module Crap4Ruby
14
14
  @stderr = stderr
15
15
  end
16
16
 
17
- # Runs the requested analysis and replaces the snapshot after successful scoring.
17
+ # Runs the requested analysis and replaces the snapshot unless --no-save is set.
18
18
  # Help and version requests produce output without writing a snapshot.
19
19
  # Expected usage, input, filesystem, and command errors are printed to stderr.
20
20
  #
@@ -34,9 +34,11 @@ module Crap4Ruby
34
34
  files = Discovery.call(root: root, source_roots: options[:source_roots], paths: paths, changed: options[:changed])
35
35
  coverage = load_coverage(options, root) unless options[:no_coverage] || files.empty?
36
36
  entries = Report.sorted(analyze(files, coverage))
37
- path = Report.write(entries, root: root)
37
+ unless options[:no_save]
38
+ path = Report.write(entries, root: root)
39
+ @stderr.puts("Wrote #{path}")
40
+ end
38
41
  @stdout.write(Report.table(entries))
39
- @stderr.puts("Wrote #{path}")
40
42
  threshold_status(entries, options[:threshold])
41
43
  rescue Error, OptionParser::ParseError, SystemCallError => error
42
44
  @stderr.puts("crap4ruby: #{error.message}")
@@ -75,6 +77,7 @@ module Crap4Ruby
75
77
  options[:coverage] = path
76
78
  end
77
79
  cli.on("--no-coverage", "Complexity only; coverage and CRAP are N/A") { options[:no_coverage] = true }
80
+ cli.on("--no-save", "Print results without writing .metrics/crap.edn") { options[:no_save] = true }
78
81
  cli.on("--use-existing-coverage", "Read reports without running tests (the default)") do
79
82
  options[:existing] = true
80
83
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Crap4Ruby
4
4
  # Gem version used by the CLI and release process.
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
data/sig/crap4ruby.rbs CHANGED
@@ -95,7 +95,7 @@ module Crap4Ruby
95
95
 
96
96
  class CLI
97
97
  type options = { root: String, source_roots: Array[String], changed: bool, coverage: String,
98
- ?help: bool, ?version: bool, ?no_coverage: bool, ?existing: bool, ?command: String, ?threshold: Rational }
98
+ ?help: bool, ?version: bool, ?no_coverage: bool, ?no_save: bool, ?existing: bool, ?command: String, ?threshold: Rational }
99
99
  @stdout: _Output
100
100
  @stderr: _Output
101
101
  def initialize: (?stdout: _Output, ?stderr: _Output) -> void
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crap4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leonid Svyatov