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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3aed72758cfe5ef63b8635586386845b2b3766a742cb398a9fc8121bd70e966f
4
- data.tar.gz: 98e694a96ccff107b670de06d747b3a015a361a1e806c190e7bc6f9c36c0ec5f
3
+ metadata.gz: 736495bc6e9ad8785b755afb2b3a834cd0dff2e62983b0397e4d6fdf6f0fe3af
4
+ data.tar.gz: 958489e0a1a542230ad57dc8748ef4a231e9c03cea1452c34246887e9789746f
5
5
  SHA512:
6
- metadata.gz: 889952ad1338856df2c539e199a18805236921b647add649937a9cfcec99578504915a000fd8174edeef13e485cab5cdda8a3ed03aa8e1a2273fe99bd5049235
7
- data.tar.gz: 1de357aa82135b51d0c31b7515c102aa251bd489495f290aeaf71db302c2acc2bd19fee7dcc3410d7f1bf5e587b8852874994b02e61df6c03684114e5be53f9d
6
+ metadata.gz: ba81b385db041ea25c62a0777838d84ed89a165e489d6d4ef3f60ea908902acad3ba2a186e3eb7325a7520f407eead2ae3e6121fd8f4429664a3a9f00a848b01
7
+ data.tar.gz: e076e78ce56f6e8e7ed238f7fa354dfe9799b2707520394e5635162f8029359c581bf5d055b53efd0c0739b58410c59ee5cb9e94c08b7dd600ecf64f478fb7d4
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![CI](https://github.com/sergeiboikov/piggly/actions/workflows/ci.yml/badge.svg)](https://github.com/sergeiboikov/piggly/actions/workflows/ci.yml)
1
+ [![CI](https://github.com/NSDDeveloper/piggly/actions/workflows/ci.yml/badge.svg)](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/sergeiboikov/piggly.git
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/sergeiboikov/piggly/issues).
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
- unless html_report_requested || sonar_path
51
- puts "Warning: No report output specified. Use -o for HTML reports or -x for Sonar report."
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 or -x for Sonar report"
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
@@ -23,7 +23,7 @@ module Piggly
23
23
  data = trace.compile(procedure)
24
24
 
25
25
  return :html => traverse(data[:tree], profile),
26
- :lines => 1 .. procedure.source(@config).count("\n") + 1
26
+ :lines => 1 .. Util::LineNumbers.count(procedure.source(@config))
27
27
  end
28
28
 
29
29
  protected
@@ -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
- lines = source.split("\n")
96
- return true if line_number < 1 || line_number > lines.length
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
- # Calculate line numbers by counting newlines
141
- # Line numbers are 1-based
142
- start_line = source[0...start_pos].count("\n") + 1
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