question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

diff-quality --options with quotes do not pass to subprocess properly

See original GitHub issue

To reproduce, I created a test branch and touched one long line in a “migrations” directory. I then ran the example given in the docs:

(addgene-core)pam@bento-local:/projects/addgene-core$ diff-quality --violations=pep8 --options="--exclude='*/migrations*' --statistics" pep8_report.txt
No handlers could be found for logger "diff_cover.tool"
-------------
Diff Quality
Quality Report: pep8
Diff: origin/master...HEAD, staged, and unstaged changes
-------------
src/django/lims/tasks/migrations/0001_initial.py (0.0%):
    24: E501 line too long (130 > 79 characters)
-------------
Total:   1 line
Violations: 1 line
% Quality: 0%
-------------

Diff Cover Version:

(addgene-core)pam@bento-local:/projects/addgene-core$ pip freeze | grep diff
diff-cover==0.9.5

My analysis:

  1. This is a “hard problem” with passing quotes in arguments to Popen (command_runner.py) I think it would work with “shell=True”, but that entails a number of security concerns.
  2. The tests make sure that the “–options” value is parsed from the diff-quality command line (test_args.py), but there is no integration test of an “–options” with embedded quotes (test_integrations.py only tests --options="--violations_test_file.py"

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Bachmann1234commented, Sep 26, 2016

WOW that got long. Let me TLDR that.

I think the fix would require changes to how diff-quality generates reports that may be good but I am simply not going to get to in the near term.

However, you can work around the issue by generating the report and passing the already completed report to diff-quality. (see example at the end of the giant comment)

0reactions
Bachmann1234commented, Oct 13, 2016

Sorry to be dense but I just tried to reproduce this and failed to (Version 0.9.9)

(venv) ~/Desktop/testProject   repor   pep8 --exclude='*/migrations*,*/vendor*' . > /tmp/pep8-report.txt
(venv) ✘  ~/Desktop/testProject   repor  diff-quality --fail-under=100 --violations=pep8 --compare-branch=master /tmp/pep8-report.txt

-------------
Diff Quality
Quality Report: pep8
Diff: master...HEAD, staged, and unstaged changes
-------------
src/django/addgene/management/commands/giraffe_reanalyze.py (66.7%):
    119: E127 continuation line over-indented for visual indent
    122: E124 closing bracket does not match visual indentation
    136: E222 multiple spaces after operator
-------------
Total:   9 lines
Violations: 3 lines
% Quality: 66%
-------------
Failure. Quality is below 100.0%.

I put the reop here https://github.com/Bachmann1234/diff-cover-issue-50/

The branch I was using is repor

Read more comments on GitHub >

github_iconTop Results From Across the Web

diff-quality --options with quotes do not pass to subprocess ...
The tests make sure that the "--options" value is parsed from the diff-quality command line (test_args.py), but there is no integration test of ......
Read more >
Subprocess.popen() cannot use quotation marks within ...
On Windows, a string is a native API. To avoid unnecessary conversions, pass the command as a string: #!/usr/bin/env python from __future__ ...
Read more >
subprocess — Subprocess management — Python 3.11.1 ...
On POSIX, if args is a string, the string is interpreted as the name or path of the program to execute. However, this...
Read more >
subprocess – Work with additional processes - PyMOTW
The subprocess module provides a consistent interface to creating and working with additional processes. It offers a higher-level interface than some of the ......
Read more >
Spawning subprocesses smartly and securely - Chris Warrick
BSD, updates/patches), which means different option names or other behaviors. the program's output is not what you expected due to user config ( ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found