-
Notifications
You must be signed in to change notification settings - Fork 581
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CPDBear: Fix for crash when many files are given #1429
base: master
Are you sure you want to change the base?
Conversation
7f082b7
to
8f2ec83
Compare
84a11db
to
c262854
Compare
circle.yml
Outdated
@@ -11,7 +11,7 @@ dependencies: | |||
- ~/.cabal | |||
- ~/infer-linux64-v0.7.0 | |||
- ~/nltk_data | |||
- ~/pmd-bin-5.4.1 | |||
- ~/pmd-bin-5.5.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You forogt to change the version in .travis.yml
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, thanks! I really missed that out
bears/general/CPDBear.py
Outdated
@@ -102,6 +108,8 @@ def run(self, language: str, minimum_tokens: int=20, | |||
|
|||
stdout_output, _ = run_shell_command(arguments) | |||
|
|||
os.unlink(temp_filepath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use os.remove
? Seems they are functionally identical...
Imo os.remove
is better to understand, what do you think? :)
bears/general/CPDBear.py
Outdated
@@ -102,6 +108,8 @@ def run(self, language: str, minimum_tokens: int=20, | |||
|
|||
stdout_output, _ = run_shell_command(arguments) | |||
|
|||
os.unlink(temp_filepath) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also here, why not use temp.name
? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not sure that the object still had the file name after closing, I will change that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As delete=False
I think it should be still valid 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alternatively, you could use with ... as ...
:) (Not completely sure if it exists though)
I see that on JavaPMDBear, the root directory is sent to pmd do analyze. Should i do that here too? But this would void the ignored files |
@impmihai does this improve the results? Or is it just a shortcut for |
@Makman2 it's the second. Then I am waiting for the dependency fixes to be pushed before finishing this up. Thanks for the review! :) |
Do you need dependency fixes? Just don't pass the directory :O |
c262854
to
5f8d104
Compare
055b403
to
4920f87
Compare
4920f87
to
51ee989
Compare
May I get some help with the tests? It is failing tests from other bears, I have not yet written a test for it because I wanted to have a code that works firstly. But this is really hard for me to understand why i get coverage issues like it throws,.. |
Those are weird indeed... try to rebase, if fails reoccur we need to investigate more^^ |
Or if you are already up-to-date:
to regenerate the last commit hash. |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
3 similar comments
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
your tests are still failing :/ |
if [ ! -e ~/pmd-bin-5.4.1/bin ]; then | ||
wget -nc -O ~/pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F5.4.1/pmd-bin-5.4.1.zip | ||
if [ ! -e ~/pmd-bin-5.6.1/bin ]; then | ||
wget -nc -O ~/pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F5.6.1/pmd-bin-5.6.1.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you should update pmd in a different commit
if [ ! -e ~/pmd-bin-5.4.1/bin ]; then | ||
wget -nc -O ~/pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F5.4.1/pmd-bin-5.4.1.zip | ||
if [ ! -e ~/pmd-bin-5.6.1/bin ]; then | ||
wget -nc -O ~/pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F5.6.1/pmd-bin-5.6.1.zip |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading the bear dependency is an intrinsic part of this issue, so IMO it can stay in this commit.
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
2 similar comments
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again! |
877c242
to
4e1de2b
Compare
Until now, the files to run on were given to CPD with the --files option, which would raise 'OSError: [Errno 7] Argument list too long'. Now, the files are saved in a temporary file, and that file is given to CPD with the --filelist option, which takes a csv file containing a list of files to run on. Fixes coala/coala#3701
@@ -106,6 +114,8 @@ def run(self, language: language, | |||
|
|||
stdout_output, _ = run_shell_command(arguments) | |||
|
|||
os.remove(tmp_filename) | |||
|
|||
if stdout_output: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change this to
if not stdout_output:
return
...
and if you dont want to write a test, ...
if not stdout_output: # pragma: no cover
return
...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ignore me, this is unrelated to the patch.
Create and use variables for the versions, so that the PATH line does not need to be modified so often, and the merge conflicts that causes. Use ~/.local/ where possible for installed software, so that scripts can be reused. Related to coala#1429 Related to coala#2638
if [ ! -e ~/pmd-bin-5.4.1/bin ]; then | ||
wget -nc -O ~/pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F5.4.1/pmd-bin-5.4.1.zip | ||
if [ ! -e ~/pmd-bin-5.6.1/bin ]; then | ||
wget -nc -O ~/pmd.zip https://github.com/pmd/pmd/releases/download/pmd_releases%2F5.6.1/pmd-bin-5.6.1.zip |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upgrading the bear dependency is an intrinsic part of this issue, so IMO it can stay in this commit.
@@ -106,6 +114,8 @@ def run(self, language: language, | |||
|
|||
stdout_output, _ = run_shell_command(arguments) | |||
|
|||
os.remove(tmp_filename) | |||
|
|||
if stdout_output: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, ignore me, this is unrelated to the patch.
@@ -87,7 +87,7 @@ env: | |||
- USE_PPAS="marutter/rdev staticfloat/juliareleases ondrej/golang" | |||
- R_LIB_USER=~/R/Library | |||
- LINTR_COMMENT_BOT=false | |||
- PATH="/opt/cabal/1.24/bin:$PATH:$TRAVIS_BUILD_DIR/node_modules/.bin:$TRAVIS_BUILD_DIR/vendor/bin:$HOME/dart-sdk/bin:$HOME/.cabal/bin:$HOME/infer-linux64-v0.7.0/infer/bin:$HOME/pmd-bin-5.4.1/bin:$HOME/bakalint-0.4.0:$HOME/elm-format-0.18:$HOME/.local/tailor/tailor-latest/bin:$HOME/phpmd" | |||
- PATH="/opt/cabal/1.24/bin:$PATH:$TRAVIS_BUILD_DIR/node_modules/.bin:$TRAVIS_BUILD_DIR/vendor/bin:$HOME/dart-sdk/bin:$HOME/.cabal/bin:$HOME/infer-linux64-v0.7.0/infer/bin:$HOME/pmd-bin-5.6.1/bin:$HOME/bakalint-0.4.0:$HOME/elm-format-0.18:$HOME/.local/tailor/tailor-latest/bin:$HOME/phpmd" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change wont be required any more
@@ -102,6 +109,8 @@ def run(self, language: str, minimum_tokens: int=20, | |||
|
|||
stdout_output, _ = run_shell_command(arguments) | |||
|
|||
os.remove(tmp_filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While useful, I dont think it is worth the effort.
@@ -13,7 +13,7 @@ dependencies: | |||
- ~/.ghc-mod | |||
- ~/infer-linux64-v0.7.0 | |||
- ~/nltk_data | |||
- ~/pmd-bin-5.4.1 | |||
- ~/pmd-bin-5.6.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to circle.yml
shouldnt be needed any more due to a724ad7
Until now, the files to run on were given to CPD with
the --files option, which would raise
'OSError: [Errno 7] Argument list too long'. Now, the
files are saved in a temporary file, and that file is
given to CPD with the --filelist option, which takes a
csv file containing a list of files to run on.
Fixes coala/coala#3701
For short term contributors: we understand that getting your commits well
defined like we require is a hard task and takes some learning. If you
look to help without wanting to contribute long term there's no need
for you to learn this. Just drop us a message and we'll take care of brushing
up your stuff for merge!
Checklist
them.
individually. It is not sufficient to have "fixup commits" on your PR,
our bot will still report the issues for the previous commit.) You will
likely receive a lot of bot comments and build failures if coala does not
pass on every single commit!
After you submit your pull request, DO NOT click the 'Update Branch' button.
When asked for a rebase, consult coala.io/rebase
instead.
Please consider helping us by reviewing other peoples pull requests as well:
cobot mark wip <URL>
to get it outof the review queue.
The more you review, the more your score will grow at coala.io and we will
review your PRs faster!