eager_eye 0.7.0 → 0.8.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/CHANGELOG.md +12 -0
- data/README.md +40 -0
- data/lib/eager_eye/rspec/matchers.rb +71 -0
- data/lib/eager_eye/rspec.rb +8 -0
- data/lib/eager_eye/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 39f1ea38bf95b25a50a9dc854b1727811ffeadaeb5724e99f3e6160b2867dd79
|
|
4
|
+
data.tar.gz: db049f2205a44e3317d891d2c6c2dbda8f716562916bde05e151b97e532181af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb4e89fa8d8206a556c9ca7d12d33ee0412091aba756abc0d0581b8ca20907898eb0ed74940f75c2afae727ed2825dd65472222edd566d9cfa8a8978969f0d3e
|
|
7
|
+
data.tar.gz: b34651d34df75eafa06175af3f715948995b9a2896910a4e4ec69f9c7464a1f4d7fdbf1efb844e34b50fa2fb9d5a4f55da8089fb0b1b50aef767bff70695e327
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.8.0] - 2025-12-16
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **RSpec Integration** - RSpec matchers for testing your codebase
|
|
15
|
+
- `pass_eager_eye` matcher for testing files and directories
|
|
16
|
+
- `only` option to run specific detectors
|
|
17
|
+
- `exclude` option to exclude files by glob pattern
|
|
18
|
+
- `max_issues` option for gradual migration (allows up to N issues)
|
|
19
|
+
- `require "eager_eye/rspec"` for easy integration
|
|
20
|
+
- Helpful failure messages with issue details
|
|
21
|
+
|
|
10
22
|
## [0.7.0] - 2025-12-15
|
|
11
23
|
|
|
12
24
|
### Added
|
data/README.md
CHANGED
|
@@ -358,6 +358,46 @@ Apply this fix? [y/n/q] y
|
|
|
358
358
|
|
|
359
359
|
> **Warning:** Auto-fix is experimental. Always review changes and run your test suite after applying fixes.
|
|
360
360
|
|
|
361
|
+
## RSpec Integration
|
|
362
|
+
|
|
363
|
+
EagerEye provides RSpec matchers for testing your codebase:
|
|
364
|
+
|
|
365
|
+
```ruby
|
|
366
|
+
# spec/rails_helper.rb
|
|
367
|
+
require "eager_eye/rspec"
|
|
368
|
+
|
|
369
|
+
# spec/eager_eye_spec.rb
|
|
370
|
+
RSpec.describe "EagerEye Analysis" do
|
|
371
|
+
it "controllers have no N+1 issues" do
|
|
372
|
+
expect("app/controllers").to pass_eager_eye
|
|
373
|
+
end
|
|
374
|
+
|
|
375
|
+
it "serializers are clean" do
|
|
376
|
+
expect("app/serializers").to pass_eager_eye(only: [:serializer_nesting])
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Allow some issues during migration
|
|
380
|
+
it "legacy code is acceptable" do
|
|
381
|
+
expect("app/services/legacy").to pass_eager_eye(max_issues: 10)
|
|
382
|
+
end
|
|
383
|
+
|
|
384
|
+
it "models have no callback issues except legacy" do
|
|
385
|
+
expect("app/models").to pass_eager_eye(
|
|
386
|
+
only: [:callback_query],
|
|
387
|
+
exclude: ["app/models/legacy/**"]
|
|
388
|
+
)
|
|
389
|
+
end
|
|
390
|
+
end
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
### Matcher Options
|
|
394
|
+
|
|
395
|
+
| Option | Type | Description |
|
|
396
|
+
|--------|------|-------------|
|
|
397
|
+
| `only` | `Array<Symbol>` | Run only specified detectors |
|
|
398
|
+
| `exclude` | `Array<String>` | Glob patterns to exclude |
|
|
399
|
+
| `max_issues` | `Integer` | Maximum allowed issues (default: 0) |
|
|
400
|
+
|
|
361
401
|
## Configuration
|
|
362
402
|
|
|
363
403
|
### Config File (.eager_eye.yml)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module EagerEye
|
|
4
|
+
module RSpec
|
|
5
|
+
module Matchers
|
|
6
|
+
def pass_eager_eye(options = {})
|
|
7
|
+
PassEagerEyeMatcher.new(options)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
class PassEagerEyeMatcher
|
|
11
|
+
def initialize(options = {})
|
|
12
|
+
@only = options[:only]
|
|
13
|
+
@exclude = options[:exclude] || []
|
|
14
|
+
@max_issues = options[:max_issues] || 0
|
|
15
|
+
@issues = []
|
|
16
|
+
@path = nil
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def matches?(path)
|
|
20
|
+
@path = path
|
|
21
|
+
configure_eager_eye
|
|
22
|
+
analyzer = build_analyzer
|
|
23
|
+
@issues = analyzer.run
|
|
24
|
+
@issues.count <= @max_issues
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def failure_message
|
|
28
|
+
message = "expected #{@path} to pass EagerEye analysis"
|
|
29
|
+
message += " (max #{@max_issues} issues)" if @max_issues.positive?
|
|
30
|
+
message += ", but found #{@issues.count} issue(s):\n\n"
|
|
31
|
+
|
|
32
|
+
@issues.group_by(&:file_path).each do |file, file_issues|
|
|
33
|
+
message += "#{file}:\n"
|
|
34
|
+
file_issues.each do |issue|
|
|
35
|
+
message += " Line #{issue.line_number}: [#{issue.detector}] #{issue.message}\n"
|
|
36
|
+
end
|
|
37
|
+
message += "\n"
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
message
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def failure_message_when_negated
|
|
44
|
+
"expected #{@path} to have EagerEye issues, but it passed"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def description
|
|
48
|
+
desc = "pass EagerEye analysis"
|
|
49
|
+
desc += " for #{@only.join(", ")}" if @only
|
|
50
|
+
desc += " (max #{@max_issues} issues)" if @max_issues.positive?
|
|
51
|
+
desc
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
private
|
|
55
|
+
|
|
56
|
+
def configure_eager_eye
|
|
57
|
+
EagerEye.reset_configuration!
|
|
58
|
+
EagerEye.configure do |config|
|
|
59
|
+
config.enabled_detectors = @only if @only
|
|
60
|
+
config.excluded_paths = @exclude unless @exclude.empty?
|
|
61
|
+
config.fail_on_issues = false
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def build_analyzer
|
|
66
|
+
EagerEye::Analyzer.new(paths: [@path])
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
data/lib/eager_eye/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eager_eye
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- hamzagedikkaya
|
|
@@ -80,6 +80,8 @@ files:
|
|
|
80
80
|
- lib/eager_eye/reporters/base.rb
|
|
81
81
|
- lib/eager_eye/reporters/console.rb
|
|
82
82
|
- lib/eager_eye/reporters/json.rb
|
|
83
|
+
- lib/eager_eye/rspec.rb
|
|
84
|
+
- lib/eager_eye/rspec/matchers.rb
|
|
83
85
|
- lib/eager_eye/version.rb
|
|
84
86
|
- sig/eager_eye.rbs
|
|
85
87
|
homepage: https://github.com/hamzagedikkaya/eager_eye
|