Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

impmihai
Copy link

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

  • I read the commit guidelines and I've followed
    them.
  • I ran coala over my code locally. (All commits have to pass
    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:

The more you review, the more your score will grow at coala.io and we will
review your PRs faster!

@impmihai impmihai force-pushed the fix-cpd-many-files branch 4 times, most recently from 7f082b7 to 8f2ec83 Compare February 14, 2017 02:51
@impmihai impmihai force-pushed the fix-cpd-many-files branch 2 times, most recently from 84a11db to c262854 Compare February 15, 2017 01:47
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
Copy link
Member

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 ;)

Copy link
Author

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

@@ -102,6 +108,8 @@ def run(self, language: str, minimum_tokens: int=20,

stdout_output, _ = run_shell_command(arguments)

os.unlink(temp_filepath)
Copy link
Member

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? :)

@@ -102,6 +108,8 @@ def run(self, language: str, minimum_tokens: int=20,

stdout_output, _ = run_shell_command(arguments)

os.unlink(temp_filepath)
Copy link
Member

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? :)

Copy link
Author

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

Copy link
Member

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 👍

Copy link
Member

@adtac adtac Feb 16, 2017

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)

@impmihai
Copy link
Author

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

@Makman2
Copy link
Member

Makman2 commented Feb 15, 2017

@impmihai does this improve the results? Or is it just a shortcut for CPD to grab all files it can find?
If it's 2nd, then you are right, we don't want to void ignored files ;)

@impmihai
Copy link
Author

@Makman2 it's the second. Then I am waiting for the dependency fixes to be pushed before finishing this up. Thanks for the review! :)

@Makman2
Copy link
Member

Makman2 commented Feb 16, 2017

Do you need dependency fixes? Just don't pass the directory :O

@impmihai
Copy link
Author

impmihai commented Jun 1, 2017

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,..

@Makman2
Copy link
Member

Makman2 commented Jun 1, 2017

Those are weird indeed... try to rebase, if fails reoccur we need to investigate more^^

@Makman2
Copy link
Member

Makman2 commented Jun 1, 2017

Or if you are already up-to-date:

git commit --amend --no-edit && git push -f

to regenerate the last commit hash.

@gitmate-bot
Copy link
Collaborator

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
@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@AsnelChristian
Copy link
Member

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
Copy link
Member

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.

Copy link
Member

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.

@gitmate-bot
Copy link
Collaborator

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
@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

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:
Copy link
Member

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

...

Copy link
Member

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.

jayvdb added a commit to jayvdb/coala-bears that referenced this pull request Jul 25, 2018
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
Copy link
Member

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:
Copy link
Member

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"
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

crash when runing coala on the libreoffice core repo