coverband 6.1.8 → 6.2.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/README.md +8 -6
- data/changes.md +7 -0
- data/lib/coverband/mcp/tools/get_dead_methods.rb +5 -5
- data/lib/coverband/reporters/web.rb +4 -4
- data/lib/coverband/utils/dead_methods.rb +4 -0
- data/lib/coverband/version.rb +1 -1
- data/test/coverband/mcp/tools/get_dead_methods_test.rb +20 -10
- data/test/coverband/reporters/web_test.rb +10 -0
- data/test/coverband/utils/dead_methods_test.rb +20 -0
- 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: 12802541de3827dd777fba9962270fd2f0a6c7b3debb2ef96c4bcca32f02b48d
|
|
4
|
+
data.tar.gz: 36fa21009ed2ada842ff90ca4a18195c8bfcddc81ad0951c11f613ede11f6606
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 03c7e496735cfe705b926b30140b3d704993b0599e470d290fb9ae672a7b204bf5cfa98adfc73d54eb70df1c71e8cbb9d91a5f85862b86d5c2a1ba1d0d3aa704
|
|
7
|
+
data.tar.gz: 6610a4ec327a69de3bd6878cb256a8f9d605fcf2a4104e6699b6b68acbec3ac9aaaeb957569eaf9ac1e949c58c5a6adbcd75055be464da56a11dde5c873dc4b6
|
data/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<img src="https://raw.github.com/danmayer/coverband/
|
|
1
|
+
<img src="https://raw.github.com/danmayer/coverband/main/docs/assets/logo/heads.svg?sanitize=true" width='300'>
|
|
2
2
|
|
|
3
3
|
# Coverband
|
|
4
4
|
|
|
5
5
|
[](https://github.com/danmayer/coverband/actions)
|
|
6
|
-
[](https://coveralls.io/github/danmayer/coverband?branch=main)
|
|
7
7
|
[](https://codeclimate.com/github/danmayer/coverband/maintainability)
|
|
8
8
|
[](https://discord.gg/KAH38EV)
|
|
9
9
|
|
|
@@ -57,7 +57,7 @@ gem 'coverband'
|
|
|
57
57
|
|
|
58
58
|
With older versions of Coverband, projects would report to redis using rack or sidekiq middleware. After Coverband 4.0, this should no longer be required and could cause performance issues. Reporting to redis is now automatically done within a background thread with no custom code needed.
|
|
59
59
|
|
|
60
|
-
See [changelog](https://github.com/danmayer/coverband/blob/
|
|
60
|
+
See [changelog](https://github.com/danmayer/coverband/blob/main/changes.md).
|
|
61
61
|
|
|
62
62
|
## Rails
|
|
63
63
|
|
|
@@ -77,10 +77,12 @@ run ActionController::Dispatcher.new
|
|
|
77
77
|
|
|
78
78
|
## Coverband Web UI
|
|
79
79
|
|
|
80
|
-

|
|
81
81
|
|
|
82
82
|
> You can check it out locally by running the [Coverband Demo App](https://github.com/danmayer/coverband_rails_example).
|
|
83
83
|
|
|
84
|
+
- View a shared demo at [https://coverband-rails-example.onrender.com/](https://coverband-rails-example.onrender.com/)
|
|
85
|
+
|
|
84
86
|
- View overall coverage information
|
|
85
87
|
|
|
86
88
|
- Drill into individual file coverage
|
|
@@ -208,7 +210,7 @@ Take Coverband for a spin on the live Heroku deployed [Coverband Demo](https://c
|
|
|
208
210
|
|
|
209
211
|
If you need to configure Coverband, this can be done by creating a `config/coverband.rb` file relative to your project root.
|
|
210
212
|
|
|
211
|
-
- See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/
|
|
213
|
+
- See [lib/coverband/configuration.rb](https://github.com/danmayer/coverband/blob/main/lib/coverband/configuration.rb) for all options
|
|
212
214
|
- By default Coverband will try to store data to Redis \* Redis endpoint is looked for in this order: `ENV['COVERBAND_REDIS_URL']`, `ENV['REDIS_URL']`, or `localhost`
|
|
213
215
|
|
|
214
216
|
Below is an example config file for a Rails 5 app:
|
|
@@ -269,7 +271,7 @@ This feature is enabled by default. To stop this feature, disable the feature in
|
|
|
269
271
|
|
|
270
272
|
`config.track_views = false`
|
|
271
273
|
|
|
272
|
-

|
|
273
275
|
|
|
274
276
|
### Hiding settings
|
|
275
277
|
|
data/changes.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
### 6.2.0
|
|
2
|
+
|
|
3
|
+
* Fix: Correct `Rack::Static` URL handling in the web reporter by using an empty string URL prefix; thanks @alpaca-tc (#635)
|
|
4
|
+
* Fix: Skip missing files during dead method scans to avoid errors in dynamic or removed-file environments; thanks @doug-hall (#632)
|
|
5
|
+
* Fix: Improve MCP dead method formatting for clearer tool output; thanks @doug-hall (#633)
|
|
6
|
+
* Docs: README updates (including `master` → `main` wording updates); thanks @jjb (#627)
|
|
7
|
+
|
|
1
8
|
### 6.1.8
|
|
2
9
|
|
|
3
10
|
* Feature: Added temporal data to GetFileCoverage tool for MCP by @fabienpiette (#626)
|
|
@@ -28,21 +28,21 @@ module Coverband
|
|
|
28
28
|
|
|
29
29
|
if file_pattern
|
|
30
30
|
dead_methods = dead_methods.select do |method|
|
|
31
|
-
File.fnmatch(file_pattern, method
|
|
31
|
+
File.fnmatch(file_pattern, method.file_path, File::FNM_PATHNAME)
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
# Group by file for easier reading
|
|
36
|
-
grouped = dead_methods.group_by
|
|
36
|
+
grouped = dead_methods.group_by(&:file_path)
|
|
37
37
|
|
|
38
38
|
result = grouped.map do |file_path, methods|
|
|
39
39
|
{
|
|
40
40
|
file: file_path,
|
|
41
41
|
dead_methods: methods.map do |m|
|
|
42
42
|
{
|
|
43
|
-
class_name: m
|
|
44
|
-
method_name: m
|
|
45
|
-
line_number: m
|
|
43
|
+
class_name: m.class_name,
|
|
44
|
+
method_name: m.name,
|
|
45
|
+
line_number: m.first_line_number
|
|
46
46
|
}
|
|
47
47
|
end
|
|
48
48
|
}
|
|
@@ -32,9 +32,9 @@ module Coverband
|
|
|
32
32
|
|
|
33
33
|
def init_web
|
|
34
34
|
full_path = Gem::Specification.find_by_name("coverband").full_gem_path
|
|
35
|
-
@
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
@file_server = Rack::Files.new(
|
|
36
|
+
File.expand_path("public", full_path)
|
|
37
|
+
)
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def check_auth
|
|
@@ -85,7 +85,7 @@ module Coverband
|
|
|
85
85
|
else
|
|
86
86
|
case request_path_info
|
|
87
87
|
when /.*\.(css|js|gif|png)/
|
|
88
|
-
@
|
|
88
|
+
@file_server.get(env)
|
|
89
89
|
when %r{/settings}
|
|
90
90
|
[200, coverband_headers, [settings]]
|
|
91
91
|
when %r{/view_tracker_data}
|
|
@@ -43,7 +43,11 @@ module Coverband
|
|
|
43
43
|
# and runtime phases.
|
|
44
44
|
coverage = Coverband.configuration.store.get_coverage_report[Coverband::MERGED_TYPE]
|
|
45
45
|
coverage.flat_map do |file_path, coverage|
|
|
46
|
+
next [] unless File.exist?(file_path)
|
|
47
|
+
|
|
46
48
|
scan(file_path: file_path, coverage: coverage["data"])
|
|
49
|
+
rescue Errno::ENOENT
|
|
50
|
+
[]
|
|
47
51
|
end
|
|
48
52
|
end
|
|
49
53
|
|
data/lib/coverband/version.rb
CHANGED
|
@@ -10,6 +10,16 @@ end
|
|
|
10
10
|
|
|
11
11
|
if defined?(Coverband::MCP)
|
|
12
12
|
class GetDeadMethodsTest < Minitest::Test
|
|
13
|
+
def build_dead_method(file_path:, class_name:, method_name:, line_number:)
|
|
14
|
+
Coverband::Utils::MethodDefinitionScanner::MethodDefinition.new(
|
|
15
|
+
first_line_number: line_number,
|
|
16
|
+
last_line_number: line_number,
|
|
17
|
+
name: method_name,
|
|
18
|
+
class_name: class_name,
|
|
19
|
+
file_path: file_path
|
|
20
|
+
)
|
|
21
|
+
end
|
|
22
|
+
|
|
13
23
|
def setup
|
|
14
24
|
super
|
|
15
25
|
Coverband.configure do |config|
|
|
@@ -35,24 +45,24 @@ if defined?(Coverband::MCP)
|
|
|
35
45
|
if defined?(RubyVM::AbstractSyntaxTree)
|
|
36
46
|
test "call returns dead methods when AST support available" do
|
|
37
47
|
mock_dead_methods = [
|
|
38
|
-
|
|
48
|
+
build_dead_method(
|
|
39
49
|
file_path: "/app/models/user.rb",
|
|
40
50
|
class_name: "User",
|
|
41
51
|
method_name: "unused_method",
|
|
42
52
|
line_number: 10
|
|
43
|
-
|
|
44
|
-
|
|
53
|
+
),
|
|
54
|
+
build_dead_method(
|
|
45
55
|
file_path: "/app/models/user.rb",
|
|
46
56
|
class_name: "User",
|
|
47
57
|
method_name: "another_unused",
|
|
48
58
|
line_number: 15
|
|
49
|
-
|
|
50
|
-
|
|
59
|
+
),
|
|
60
|
+
build_dead_method(
|
|
51
61
|
file_path: "/app/models/order.rb",
|
|
52
62
|
class_name: "Order",
|
|
53
63
|
method_name: "dead_method",
|
|
54
64
|
line_number: 20
|
|
55
|
-
|
|
65
|
+
)
|
|
56
66
|
]
|
|
57
67
|
|
|
58
68
|
Coverband::Utils::DeadMethods.expects(:scan_all).returns(mock_dead_methods)
|
|
@@ -83,18 +93,18 @@ if defined?(Coverband::MCP)
|
|
|
83
93
|
|
|
84
94
|
test "call filters by file_pattern when provided" do
|
|
85
95
|
mock_dead_methods = [
|
|
86
|
-
|
|
96
|
+
build_dead_method(
|
|
87
97
|
file_path: "/app/models/user.rb",
|
|
88
98
|
class_name: "User",
|
|
89
99
|
method_name: "unused_method",
|
|
90
100
|
line_number: 10
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
),
|
|
102
|
+
build_dead_method(
|
|
93
103
|
file_path: "/app/helpers/user_helper.rb",
|
|
94
104
|
class_name: "UserHelper",
|
|
95
105
|
method_name: "dead_helper",
|
|
96
106
|
line_number: 5
|
|
97
|
-
|
|
107
|
+
)
|
|
98
108
|
]
|
|
99
109
|
|
|
100
110
|
Coverband::Utils::DeadMethods.expects(:scan_all).returns(mock_dead_methods)
|
|
@@ -45,6 +45,16 @@ module Coverband
|
|
|
45
45
|
get "/json?line_coverage=true"
|
|
46
46
|
assert last_response.ok?
|
|
47
47
|
end
|
|
48
|
+
|
|
49
|
+
test "renders static files" do
|
|
50
|
+
get "/application.js"
|
|
51
|
+
assert last_response.ok?
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
test "renders 404 if static file doesn't exist" do
|
|
55
|
+
get "/unknown.js"
|
|
56
|
+
assert last_response.not_found?
|
|
57
|
+
end
|
|
48
58
|
end
|
|
49
59
|
end
|
|
50
60
|
|
|
@@ -48,6 +48,26 @@ if defined?(RubyVM::AbstractSyntaxTree)
|
|
|
48
48
|
assert_equal(6, dead_method.last_line_number)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
def test_scan_all_skips_missing_files
|
|
52
|
+
missing_file = "./test/fixtures/missing_file.rb"
|
|
53
|
+
existing_file = "./test/dog.rb"
|
|
54
|
+
coverage_report = {
|
|
55
|
+
Coverband::MERGED_TYPE => {
|
|
56
|
+
missing_file => {"data" => []},
|
|
57
|
+
existing_file => {"data" => []}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
dead_method = Object.new
|
|
61
|
+
|
|
62
|
+
Coverband.configuration.stubs(:store).returns(
|
|
63
|
+
stub(get_coverage_report: coverage_report)
|
|
64
|
+
)
|
|
65
|
+
DeadMethods.expects(:scan).with(file_path: existing_file, coverage: []).returns([dead_method])
|
|
66
|
+
DeadMethods.expects(:scan).with(file_path: missing_file, coverage: []).never
|
|
67
|
+
|
|
68
|
+
assert_equal [dead_method], DeadMethods.scan_all
|
|
69
|
+
end
|
|
70
|
+
|
|
51
71
|
def test_output_all
|
|
52
72
|
require_unique_file
|
|
53
73
|
@coverband.report_coverage
|