diff-quality --options with quotes do not pass to subprocess properly
See original GitHub issueTo 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:
- 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.
- 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:
- Created 7 years ago
- Comments:11 (8 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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)
Sorry to be dense but I just tried to reproduce this and failed to (Version 0.9.9)
I put the reop here https://github.com/Bachmann1234/diff-cover-issue-50/
The branch I was using is
repor