Skip to content
New issue

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

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

Already on GitHub? # to your account

diff-quality fails with ValueError: invalid literal for int() with base 10: '470]' #276

Closed
kozlovsky opened this issue Apr 14, 2022 · 2 comments · Fixed by #277
Closed

Comments

@kozlovsky
Copy link
Contributor

When running diff-quality tool I have the following exception:

Traceback (most recent call last):
  File "/usr/local/bin/diff-quality", line 8, in <module>
    sys.exit(main())
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/diff_quality_tool.py", line 348, in main
    percent_passing = generate_quality_report(
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/diff_quality_tool.py", line 261, in generate_quality_report
    reporter.generate_report(output_file)
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/report_generator.py", line 265, in generate_report
    report = template.render(self._context())
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/report_generator.py", line 314, in _context
    context = super().report_dict()
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/report_generator.py", line 187, in report_dict
    src_stats = {src: self._src_path_stats(src) for src in self.src_paths()}
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/report_generator.py", line 84, in src_paths
    for src, summary in self._diff_violations().items()
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/report_generator.py", line 176, in _diff_violations
    self._diff_violations_dict = {
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/report_generator.py", line 178, in <dictcomp>
    self._violations.violations(src_path),
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/violationsreporters/base.py", line 159, in violations
    self.violations_dict.update(self.driver.parse_reports([output]))
  File "/home/jenkins/.local/lib/python3.8/site-packages/diff_cover/violationsreporters/violations_reporter.py", line 469, in parse_reports
    violation = Violation(int(line_number), error_str)
ValueError: invalid literal for int() with base 10: '470]'

The reason for this is the following: violations_reporter expects, that the output for duplicating lines looks like:

file1.py:162: [R0801] Similar lines in 2 files
==file1:162
==student.views:4

but it can look like:

file1.py:162: [R0801] Similar lines in 2 files
==file1:[162:165]
==student.views:[4:7]

And the multi_line_violation_regex regular expression ==(\w|.+):(.*) cannot parse it correctly.

The correct regular expression is ==((?:\w|\.)+?):\[?(\d+).

@Bachmann1234
Copy link
Owner

@kozlovsky
Copy link
Contributor Author

Thanks, it works!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants