keela 0.2.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +30 -10
- data/README.md +18 -2
- data/exe/keela +9 -1
- data/lib/keela/config_file.rb +7 -6
- data/lib/keela/scanner.rb +23 -6
- data/lib/keela/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bb2b0270567d3a141ba56fe243a94c64a7adc2fde674d4e851f195158aadeda6
|
|
4
|
+
data.tar.gz: ee7ded87e34b526e74cde698c7fe69dd543ea89cc342a87d36b7466832ce8d82
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 717ddbcd2b0b44085189f081d4c332e9535200b20b7fec7e0592373371db3efa765076a27d962e30165fcc4c73603692f00232948396a4c75c83de5656f146e8
|
|
7
|
+
data.tar.gz: f47ba3b39c51b56aca08346d542f1bf9f0ec3697fef64196a467d784148a2d8f12bb3c4be189cc70e0966bee4967cc52da9a6beb69841e20ab459b1bd3e707b5
|
data/CHANGELOG.md
CHANGED
|
@@ -7,22 +7,42 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.2] - 2026-07-27
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Config file lookup now includes `.keela/config.yml` as the first option ([#30](https://github.com/kerrizor/keela/pull/30))
|
|
15
|
+
- Lookup order: `.keela/config.yml` → `keela.yml` → `.keela.yml`
|
|
16
|
+
|
|
17
|
+
## [0.2.1] - 2026-07-27
|
|
18
|
+
|
|
19
|
+
### Added
|
|
20
|
+
|
|
21
|
+
- **Quiet mode** via `--quiet` / `-q` CLI flag to suppress progress bar output ([#26](https://github.com/kerrizor/keela/issues/26))
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- Default suggested excluded filename changed from `excluded.yml` to `keela_excluded.yml` for consistency with `keela_baseline.yml` ([#28](https://github.com/kerrizor/keela/pull/28))
|
|
26
|
+
- Default file locations now support `.keela/` directory with fallback to root ([#29](https://github.com/kerrizor/keela/pull/29))
|
|
27
|
+
- Excluded: `.keela/excluded.yml` → `keela_excluded.yml`
|
|
28
|
+
- Baseline: `.keela/baseline.yml` → `keela_baseline.yml`
|
|
29
|
+
|
|
10
30
|
## [0.2.0] - 2026-07-17
|
|
11
31
|
|
|
12
32
|
### Added
|
|
13
33
|
|
|
14
34
|
- `Baseline` class for managing multi-strategy baseline files ([#1](https://github.com/kerrizor/keela/pull/1))
|
|
15
35
|
- Single baseline file now supports multiple strategy sections (methods, scopes)
|
|
16
|
-
- **Constants strategy** for detecting unused constant definitions (
|
|
17
|
-
- **Delegations strategy** for detecting unused `delegate :method, to: :target` declarations
|
|
18
|
-
- **Attributes strategy** for detecting unused `attr_accessor`, `attr_reader`, `attr_writer` declarations
|
|
19
|
-
- **Config file support** (`keela.yml` or `.keela.yml`) for project-specific settings
|
|
20
|
-
- **Exclude patterns** via `--exclude` CLI flag or `exclude_patterns` in config file
|
|
21
|
-
- **Include patterns** via `--include` CLI flag or `include_patterns` in config file (
|
|
22
|
-
- **Configuration validation** - raises `ConfigurationError` if `directory_patterns` is customized while also using `include_patterns` or `exclude_patterns`
|
|
23
|
-
- **I18n keys strategy (beta)** for detecting unused translation keys in locale files (
|
|
24
|
-
- **Multiple types** can now be specified with `--type methods,scopes,constants`
|
|
25
|
-
- **JSON output** via `--format json` for machine-readable results (
|
|
36
|
+
- **Constants strategy** for detecting unused constant definitions ([#2](https://github.com/kerrizor/keela/pull/2))
|
|
37
|
+
- **Delegations strategy** for detecting unused `delegate :method, to: :target` declarations ([#4](https://github.com/kerrizor/keela/pull/4))
|
|
38
|
+
- **Attributes strategy** for detecting unused `attr_accessor`, `attr_reader`, `attr_writer` declarations ([#5](https://github.com/kerrizor/keela/pull/5))
|
|
39
|
+
- **Config file support** (`keela.yml` or `.keela.yml`) for project-specific settings ([#11](https://github.com/kerrizor/keela/pull/11))
|
|
40
|
+
- **Exclude patterns** via `--exclude` CLI flag or `exclude_patterns` in config file ([#12](https://github.com/kerrizor/keela/pull/12))
|
|
41
|
+
- **Include patterns** via `--include` CLI flag or `include_patterns` in config file ([#14](https://github.com/kerrizor/keela/pull/14))
|
|
42
|
+
- **Configuration validation** - raises `ConfigurationError` if `directory_patterns` is customized while also using `include_patterns` or `exclude_patterns` ([#15](https://github.com/kerrizor/keela/pull/15))
|
|
43
|
+
- **I18n keys strategy (beta)** for detecting unused translation keys in locale files ([#16](https://github.com/kerrizor/keela/pull/16))
|
|
44
|
+
- **Multiple types** can now be specified with `--type methods,scopes,constants` ([#18](https://github.com/kerrizor/keela/pull/18))
|
|
45
|
+
- **JSON output** via `--format json` for machine-readable results ([#19](https://github.com/kerrizor/keela/pull/19))
|
|
26
46
|
|
|
27
47
|
### Fixed
|
|
28
48
|
|
data/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# Keela 🐕
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Your Ruby codebase's forensic investigator.**
|
|
4
|
+
|
|
5
|
+
Like her namesake — the famous springer spaniel who helped solve cases by finding microscopic traces that eluded forensic teams — Keela sniffs out the dead code that `grep` missed.
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
🔍 6 strategies: methods, scopes, constants, delegates, attrs, i18n
|
|
9
|
+
🎯 Baseline mode — only bark at NEW dead code
|
|
10
|
+
📊 JSON output for CI pipelines
|
|
11
|
+
```
|
|
4
12
|
|
|
5
13
|
## Why Remove Unused Code?
|
|
6
14
|
|
|
@@ -106,6 +114,10 @@ keela --config path/to/keela.yml
|
|
|
106
114
|
# Output as JSON (for CI integrations)
|
|
107
115
|
keela --format json
|
|
108
116
|
|
|
117
|
+
# Suppress progress bar (useful for CI and scripting)
|
|
118
|
+
keela --quiet
|
|
119
|
+
keela -q
|
|
120
|
+
|
|
109
121
|
# Show version
|
|
110
122
|
keela --version
|
|
111
123
|
```
|
|
@@ -339,7 +351,11 @@ scanner.run(force_report: true)
|
|
|
339
351
|
|
|
340
352
|
## About the Name
|
|
341
353
|
|
|
342
|
-
Keela was a famous English Springer Spaniel known as the "CSI dog." She could detect microscopic traces of blood that other forensic methods missed,
|
|
354
|
+
Keela was a famous English Springer Spaniel known as the "CSI dog." She could detect microscopic traces of blood that other forensic methods missed, helping solve cases that had gone cold for decades. Her nose was so sensitive she found evidence that luminol and DNA testing couldn't.
|
|
355
|
+
|
|
356
|
+
Like her namesake, this gem finds the dead code that `grep` and your IDE missed.
|
|
357
|
+
|
|
358
|
+
*Good girl, Keela.* 🦴
|
|
343
359
|
|
|
344
360
|
## License
|
|
345
361
|
|
data/exe/keela
CHANGED
|
@@ -9,7 +9,8 @@ options = {
|
|
|
9
9
|
force_report: false,
|
|
10
10
|
update_baseline: false,
|
|
11
11
|
config_path: nil,
|
|
12
|
-
format: :text
|
|
12
|
+
format: :text,
|
|
13
|
+
quiet: false
|
|
13
14
|
}
|
|
14
15
|
|
|
15
16
|
OptionParser.new do |opts|
|
|
@@ -72,6 +73,10 @@ OptionParser.new do |opts|
|
|
|
72
73
|
exit
|
|
73
74
|
end
|
|
74
75
|
|
|
76
|
+
opts.on("--quiet", "-q", "Suppress progress bar output (useful for CI and scripting)") do
|
|
77
|
+
options[:quiet] = true
|
|
78
|
+
end
|
|
79
|
+
|
|
75
80
|
opts.on("-h", "--help", "Show this help") do
|
|
76
81
|
puts opts
|
|
77
82
|
exit
|
|
@@ -82,6 +87,9 @@ end.parse!
|
|
|
82
87
|
# CLI options override config file settings
|
|
83
88
|
Keela::ConfigFile.load(path: options[:config_path])
|
|
84
89
|
|
|
90
|
+
# Apply quiet mode if requested
|
|
91
|
+
Keela.configuration.show_progress = false if options[:quiet]
|
|
92
|
+
|
|
85
93
|
# Set default baseline path if not specified
|
|
86
94
|
Keela.configuration.baseline_path ||= ".keela_baseline.yml"
|
|
87
95
|
|
data/lib/keela/config_file.rb
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
require "yaml"
|
|
4
4
|
|
|
5
5
|
module Keela
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
# Loads configuration from a YAML file.
|
|
7
|
+
#
|
|
8
|
+
# Looks for config files in this order:
|
|
9
|
+
# 1. .keela/config.yml
|
|
10
|
+
# 2. keela.yml
|
|
11
|
+
# 3. .keela.yml
|
|
11
12
|
#
|
|
12
13
|
# Supported keys:
|
|
13
14
|
# - extensions: Array of file extensions to scan
|
|
@@ -30,7 +31,7 @@ module Keela
|
|
|
30
31
|
# - erb
|
|
31
32
|
#
|
|
32
33
|
module ConfigFile
|
|
33
|
-
CONFIG_FILENAMES = %w[keela.yml .keela.yml].freeze
|
|
34
|
+
CONFIG_FILENAMES = %w[.keela/config.yml keela.yml .keela.yml].freeze
|
|
34
35
|
|
|
35
36
|
ALLOWED_KEYS = %w[
|
|
36
37
|
extensions
|
data/lib/keela/scanner.rb
CHANGED
|
@@ -7,10 +7,13 @@ module Keela
|
|
|
7
7
|
class Scanner
|
|
8
8
|
attr_reader :strategy, :configuration, :baseline, :source_files, :unused_collection, :new_unused, :removed
|
|
9
9
|
|
|
10
|
+
DEFAULT_EXCLUDED_PATHS = [".keela/excluded.yml", "keela_excluded.yml"].freeze
|
|
11
|
+
DEFAULT_BASELINE_PATHS = [".keela/baseline.yml", "keela_baseline.yml"].freeze
|
|
12
|
+
|
|
10
13
|
def initialize(strategy:, configuration: Keela.configuration, baseline: nil)
|
|
11
14
|
@strategy = strategy
|
|
12
15
|
@configuration = configuration
|
|
13
|
-
@baseline = baseline || Baseline.new(
|
|
16
|
+
@baseline = baseline || Baseline.new(resolve_baseline_path)
|
|
14
17
|
@source_files = {}
|
|
15
18
|
@unused_collection = Hash.new { |hash, key| hash[key] = [] }
|
|
16
19
|
@new_unused = []
|
|
@@ -31,7 +34,7 @@ module Keela
|
|
|
31
34
|
# Determine mode: report if forced, updating baseline, or no baseline exists
|
|
32
35
|
report_mode = force_report || update_baseline || !baseline.exists?
|
|
33
36
|
|
|
34
|
-
find_unused(definitions, show_progress: report_mode && !silent)
|
|
37
|
+
find_unused(definitions, show_progress: report_mode && !silent && configuration.show_progress)
|
|
35
38
|
|
|
36
39
|
if report_mode
|
|
37
40
|
elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
|
|
@@ -49,7 +52,7 @@ module Keela
|
|
|
49
52
|
reporter.print_diff_report(
|
|
50
53
|
new_unused,
|
|
51
54
|
removed,
|
|
52
|
-
excluded_path:
|
|
55
|
+
excluded_path: resolve_excluded_path || ".keela/excluded.yml",
|
|
53
56
|
baseline_path: baseline.path
|
|
54
57
|
)
|
|
55
58
|
end
|
|
@@ -128,10 +131,10 @@ module Keela
|
|
|
128
131
|
end
|
|
129
132
|
|
|
130
133
|
def filter_excluded(definitions)
|
|
131
|
-
|
|
132
|
-
return definitions unless
|
|
134
|
+
path = resolve_excluded_path
|
|
135
|
+
return definitions unless path
|
|
133
136
|
|
|
134
|
-
excluded = YAML.load_file(
|
|
137
|
+
excluded = YAML.load_file(path, symbolize_names: true) || {}
|
|
135
138
|
|
|
136
139
|
definitions.reject do |h|
|
|
137
140
|
excluded_for_file = excluded[h[:file].to_sym]
|
|
@@ -139,6 +142,20 @@ module Keela
|
|
|
139
142
|
end
|
|
140
143
|
end
|
|
141
144
|
|
|
145
|
+
def resolve_excluded_path
|
|
146
|
+
return configuration.excluded_path if configuration.excluded_path && File.exist?(configuration.excluded_path)
|
|
147
|
+
|
|
148
|
+
# Check default locations in order of preference
|
|
149
|
+
DEFAULT_EXCLUDED_PATHS.find { |path| File.exist?(path) }
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def resolve_baseline_path
|
|
153
|
+
return configuration.baseline_path if configuration.baseline_path && File.exist?(configuration.baseline_path)
|
|
154
|
+
|
|
155
|
+
# Check default locations in order of preference
|
|
156
|
+
DEFAULT_BASELINE_PATHS.find { |path| File.exist?(path) }
|
|
157
|
+
end
|
|
158
|
+
|
|
142
159
|
def find_unused(definitions, show_progress: false)
|
|
143
160
|
source_code = source_files.values.flatten.join
|
|
144
161
|
|
data/lib/keela/version.rb
CHANGED