piggly-nsd 2.3.4 → 2.3.5
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 +17 -3
- data/lib/piggly/command/report.rb +25 -7
- data/lib/piggly/compiler/coverage_report.rb +1 -1
- data/lib/piggly/compiler/line_coverage.rb +7 -9
- data/lib/piggly/parser/grammar.tt +760 -748
- data/lib/piggly/reporter/schema_csv.rb +98 -0
- data/lib/piggly/reporter/sonar.rb +6 -1
- data/lib/piggly/reporter.rb +1 -0
- data/lib/piggly/task.rb +4 -1
- data/lib/piggly/util/line_numbers.rb +25 -0
- data/lib/piggly/util.rb +1 -0
- data/lib/piggly/version.rb +2 -2
- data/spec/examples/grammar/statements/loop_spec.rb +9 -0
- data/spec/examples/grammar/statements/sql_spec.rb +14 -0
- data/spec/examples/reporter/schema_csv_spec.rb +72 -0
- data/spec/examples/util/line_numbers_spec.rb +59 -0
- data/spec/issues/037_spec.rb +30 -0
- data/spec/issues/case_in_condition_spec.rb +50 -0
- data/spec/issues/commit_spec.rb +34 -0
- data/spec/spec_helper.rb +1 -1
- metadata +23 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 736495bc6e9ad8785b755afb2b3a834cd0dff2e62983b0397e4d6fdf6f0fe3af
|
|
4
|
+
data.tar.gz: 958489e0a1a542230ad57dc8748ef4a231e9c03cea1452c34246887e9789746f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ba81b385db041ea25c62a0777838d84ed89a165e489d6d4ef3f60ea908902acad3ba2a186e3eb7325a7520f407eead2ae3e6121fd8f4429664a3a9f00a848b01
|
|
7
|
+
data.tar.gz: e076e78ce56f6e8e7ed238f7fa354dfe9799b2707520394e5635162f8029359c581bf5d055b53efd0c0739b58410c59ee5cb9e94c08b7dd600ecf64f478fb7d4
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[](https://github.com/NSDDeveloper/piggly/actions/workflows/ci.yml)
|
|
2
2
|
# Piggly-NSD
|
|
3
3
|
|
|
4
4
|
Code coverage reports for PostgreSQL PL/pgSQL stored procedures
|
|
@@ -60,7 +60,7 @@ This fork continues the version numbering from the original piggly project:
|
|
|
60
60
|
|
|
61
61
|
To install the latest from github:
|
|
62
62
|
|
|
63
|
-
$ git clone https://github.com/
|
|
63
|
+
$ git clone https://github.com/NSDDeveloper/piggly.git
|
|
64
64
|
$ cd piggly
|
|
65
65
|
$ bundle install
|
|
66
66
|
$ bundle exec rake spec
|
|
@@ -139,6 +139,20 @@ To generate a SonarQube-compatible coverage report, use the `--sonar-report-path
|
|
|
139
139
|
|
|
140
140
|
This generates an XML file in SonarQube's [generic test coverage format](https://docs.sonarsource.com/sonarqube-server/latest/analyzing-source-code/test-coverage/generic-test-data/).
|
|
141
141
|
|
|
142
|
+
### Schema CSV Report
|
|
143
|
+
|
|
144
|
+
To generate a schema-level CSV report, use the `--schema-csv-path` option:
|
|
145
|
+
|
|
146
|
+
$ piggly report -f messages.txt --schema-csv-path piggly/reports/coverage_by_schema.csv
|
|
147
|
+
|
|
148
|
+
The CSV report groups procedures by schema and contains the following columns:
|
|
149
|
+
|
|
150
|
+
- `No`
|
|
151
|
+
- `Schema Name`
|
|
152
|
+
- `Objects Count`
|
|
153
|
+
- `Covered Objects`
|
|
154
|
+
- `Line Coverage Percent`
|
|
155
|
+
|
|
142
156
|
## Running the Examples
|
|
143
157
|
|
|
144
158
|
$ cd piggly
|
|
@@ -179,4 +193,4 @@ This generates an XML file in SonarQube's [generic test coverage format](https:/
|
|
|
179
193
|
|
|
180
194
|
## Bugs & Issues
|
|
181
195
|
|
|
182
|
-
Please report any issues or feature requests on the [github tracker](https://github.com/
|
|
196
|
+
Please report any issues or feature requests on the [github tracker](https://github.com/NSDDeveloper/piggly/issues).
|
|
@@ -13,7 +13,7 @@ module Piggly
|
|
|
13
13
|
class << Report
|
|
14
14
|
def main(argv)
|
|
15
15
|
require "pp"
|
|
16
|
-
io, config, sonar_path, html_report_requested = configure(argv)
|
|
16
|
+
io, config, sonar_path, schema_csv_path, html_report_requested = configure(argv)
|
|
17
17
|
|
|
18
18
|
profile = Profile.new
|
|
19
19
|
index = Dumper::Index.new(config)
|
|
@@ -46,9 +46,14 @@ module Piggly
|
|
|
46
46
|
if sonar_path
|
|
47
47
|
create_sonar_report(config, procedures, profile, sonar_path)
|
|
48
48
|
end
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
|
|
50
|
+
# Generate schema-level CSV report if requested
|
|
51
|
+
if schema_csv_path
|
|
52
|
+
create_schema_csv_report(config, procedures, profile, schema_csv_path)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
unless html_report_requested || sonar_path || schema_csv_path
|
|
56
|
+
puts "Warning: No report output specified. Use -o for HTML reports, -x for Sonar report, or --schema-csv-path for CSV report."
|
|
52
57
|
end
|
|
53
58
|
end
|
|
54
59
|
|
|
@@ -138,9 +143,19 @@ module Piggly
|
|
|
138
143
|
puts "Sonar coverage report written to: #{path}"
|
|
139
144
|
end
|
|
140
145
|
|
|
146
|
+
# Create schema-level CSV coverage report
|
|
147
|
+
#
|
|
148
|
+
def create_schema_csv_report(config, procedures, profile, output_path)
|
|
149
|
+
puts "creating schema CSV coverage report"
|
|
150
|
+
reporter = Reporter::SchemaCsv.new(config, profile, output_path)
|
|
151
|
+
path = reporter.report(procedures)
|
|
152
|
+
puts "Schema CSV coverage report written to: #{path}"
|
|
153
|
+
end
|
|
154
|
+
|
|
141
155
|
def configure(argv, config = Config.new)
|
|
142
156
|
io = $stdin
|
|
143
157
|
sonar_path = nil
|
|
158
|
+
schema_csv_path = nil
|
|
144
159
|
html_report_requested = false
|
|
145
160
|
|
|
146
161
|
p = OptionParser.new do |o|
|
|
@@ -155,6 +170,9 @@ module Piggly
|
|
|
155
170
|
o.on("-x", "--sonar-report-path PATH", "generate Sonar coverage XML report at PATH") do |path|
|
|
156
171
|
sonar_path = path
|
|
157
172
|
end
|
|
173
|
+
o.on("--schema-csv-path PATH", "generate schema-level CSV coverage report at PATH") do |path|
|
|
174
|
+
schema_csv_path = path
|
|
175
|
+
end
|
|
158
176
|
o.on("-a", "--accumulate", "accumulate data from the previous run", &o_accumulate(config))
|
|
159
177
|
o.on("-V", "--version", "show version", &o_version(config))
|
|
160
178
|
o.on("-h", "--help", "show this message") { abort o.to_s }
|
|
@@ -170,9 +188,9 @@ module Piggly
|
|
|
170
188
|
begin
|
|
171
189
|
p.parse! argv
|
|
172
190
|
|
|
173
|
-
unless html_report_requested || sonar_path
|
|
191
|
+
unless html_report_requested || sonar_path || schema_csv_path
|
|
174
192
|
raise OptionParser::MissingArgument,
|
|
175
|
-
"at least one report type required: use -o for HTML reports
|
|
193
|
+
"at least one report type required: use -o for HTML reports, -x for Sonar report, or --schema-csv-path for CSV report"
|
|
176
194
|
end
|
|
177
195
|
|
|
178
196
|
if io.eql?($stdin) and $stdin.tty?
|
|
@@ -180,7 +198,7 @@ module Piggly
|
|
|
180
198
|
"stdin must be a pipe, or use --input PATH"
|
|
181
199
|
end
|
|
182
200
|
|
|
183
|
-
return io, config, sonar_path, html_report_requested
|
|
201
|
+
return io, config, sonar_path, schema_csv_path, html_report_requested
|
|
184
202
|
rescue OptionParser::InvalidOption,
|
|
185
203
|
OptionParser::InvalidArgument,
|
|
186
204
|
OptionParser::MissingArgument
|
|
@@ -92,10 +92,10 @@ module Piggly
|
|
|
92
92
|
# @param line_number [Integer] 1-based line number
|
|
93
93
|
# @return [Boolean] true if line should be excluded
|
|
94
94
|
def excluded_line?(source, line_number)
|
|
95
|
-
|
|
96
|
-
return true if line_number < 1 || line_number >
|
|
97
|
-
|
|
98
|
-
line_content = lines[line_number - 1].strip.downcase
|
|
95
|
+
max_line = Util::LineNumbers.count(source)
|
|
96
|
+
return true if line_number < 1 || line_number > max_line
|
|
97
|
+
|
|
98
|
+
line_content = source.lines[line_number - 1].strip.downcase
|
|
99
99
|
|
|
100
100
|
# Exclude lines containing only structural keywords or comments
|
|
101
101
|
excluded_patterns = [
|
|
@@ -137,11 +137,9 @@ module Piggly
|
|
|
137
137
|
start_pos = [start_pos, source_len - 1].min if source_len > 0
|
|
138
138
|
end_pos = [end_pos, source_len - 1].min if source_len > 0
|
|
139
139
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
end_line = source[0..end_pos].count("\n") + 1
|
|
144
|
-
|
|
140
|
+
start_line = Util::LineNumbers.at_offset(source, start_pos)
|
|
141
|
+
end_line = Util::LineNumbers.at_offset(source, end_pos + 1)
|
|
142
|
+
|
|
145
143
|
[start_line, end_line]
|
|
146
144
|
end
|
|
147
145
|
|