Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

display code coverage context #18

Open
wants to merge 39 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0cf61a5
Update plugin.rb
rynssnjn Oct 11, 2023
087d594
Update plugin.rb
rynssnjn Oct 11, 2023
ee31479
Update README.md
rynssnjn Oct 11, 2023
2ab5b5e
Update plugin.rb
rynssnjn Oct 11, 2023
5fc109c
Update plugin.rb
rynssnjn Oct 11, 2023
2c041e0
Update plugin.rb
rynssnjn Oct 11, 2023
6f29980
Update plugin.rb
rynssnjn Oct 11, 2023
36714a3
Update plugin.rb
rynssnjn Oct 11, 2023
3c0d4ae
Update plugin.rb
rynssnjn Oct 11, 2023
937dd1f
Update plugin.rb
rynssnjn Oct 11, 2023
2128e0e
Update plugin.rb
rynssnjn Oct 11, 2023
c22736c
Update plugin.rb
rynssnjn Oct 11, 2023
6a4b311
Update plugin.rb
rynssnjn Oct 11, 2023
14daba7
Update plugin.rb
rynssnjn Oct 11, 2023
28572ca
Update plugin.rb
rynssnjn Oct 11, 2023
e87cb91
Update plugin.rb
rynssnjn Oct 11, 2023
b46ea1b
Update plugin.rb
rynssnjn Oct 11, 2023
9753e9e
Update plugin.rb
rynssnjn Oct 11, 2023
2b51607
Update plugin.rb
rynssnjn Oct 11, 2023
30fdd8d
Update plugin.rb
rynssnjn Oct 11, 2023
c5ae5bf
Update plugin.rb
rynssnjn Oct 11, 2023
40b0f97
Update plugin.rb
rynssnjn Oct 11, 2023
88203ce
Update plugin.rb
rynssnjn Oct 11, 2023
f49169b
Update plugin.rb
rynssnjn Oct 11, 2023
883017c
Update plugin.rb
rynssnjn Oct 11, 2023
07c3344
Update plugin.rb
rynssnjn Oct 11, 2023
bec87c6
Update plugin.rb
rynssnjn Oct 11, 2023
fdf1efe
Update plugin.rb
rynssnjn Oct 11, 2023
1d81544
Update plugin.rb
rynssnjn Oct 11, 2023
ca30e15
Update plugin.rb
rynssnjn Oct 11, 2023
2c8ee0f
Update plugin.rb
rynssnjn Oct 11, 2023
3da8a67
Update plugin.rb
rynssnjn Oct 11, 2023
b567fdd
Update plugin.rb
rynssnjn Oct 11, 2023
32322f6
Update plugin.rb
rynssnjn Oct 11, 2023
e685c07
Update plugin.rb
rynssnjn Oct 11, 2023
c49c421
Update plugin.rb
rynssnjn Oct 11, 2023
023580a
Update plugin.rb
rynssnjn Oct 11, 2023
553dee7
Update plugin.rb
rynssnjn Oct 11, 2023
fcbf96c
Update plugin.rb
rynssnjn Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -17,6 +17,9 @@ flutter_coverage.coverage_report_path = "./coverage/lcov.info"
# Print the code coverage message
flutter_coverage.code_coverage_message
# Print the lcov table
flutter_coverage.tests_context_message
```

## Development
46 changes: 44 additions & 2 deletions lib/flutter_coverage/plugin.rb
Original file line number Diff line number Diff line change
@@ -48,11 +48,53 @@ def code_coverage
covered_lines += line.sub('LH:', '').to_f
end
end
covered_lines / uncovered_lines * 100

coverage = covered_lines / uncovered_lines * 100

if coverage < 70
emoji = "🤔"
elsif coverage <= 85
emoji = "😀"
else
emoji = "🎉"
end

return "### Code coverage: #{coverage.round(2)}% #{emoji}"
end

def tests_context
input = File.open(coverage_report_path).read
input_lines = input.split("\n")

files = input_lines.select do |line|
line.start_with?('SF:')
end

covered_lines = input_lines.select do |line|
line.start_with?('LH:')
end

uncovered_lines = input_lines.select do |line|
line.start_with?('LF:')
end

table = "### Code coverage context: 👁️\n"
table << "| File | Covered |\n"
table << "| ---- | ------- |\n"

files.each_with_index do | element, index |
table << "| #{element.sub('SF:', '')} | #{(covered_lines[index].sub('LH:', '').to_f / uncovered_lines[index].sub('LF:', '').to_f * 100).round(2)}% |\n"
end

return table
end

def code_coverage_message
markdown("## Code coverage: #{code_coverage.round(2)}% ✅")
markdown(code_coverage)
end

def tests_context_message
markdown(tests_context)
end
end
end