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

JavaPMDBear is not found #998

Closed
sils opened this issue Nov 15, 2016 · 15 comments
Closed

JavaPMDBear is not found #998

sils opened this issue Nov 15, 2016 · 15 comments

Comments

@sils
Copy link
Member

sils commented Nov 15, 2016

From @rpau on November 15, 2016 10:6

Hi,

When I run

coala --show-bears --filter-by-language java

The JavaPMDBear not appears in the list. Any suggestion?

CPDBear
CheckstyleBear
FilenameBear
InferBear
InvalidLinkBear
KeywordBear
LineCountBear
LineLengthBear
SpaceConsistencyBear
coalaBear

Copied from original issue: coala/bear-docs#21

@sils
Copy link
Member Author

sils commented Nov 15, 2016

Interesting, which release? (coala -v)

@rpau
Copy link

rpau commented Nov 15, 2016

The last one (0.8.1). Finally, I have realized that CPDBear is the JavaPMDBear.
So, I should put a comment in the documentation and remove the JavaPMDBear entry.

Another related issue... and I do not know if it is the right place. I am trying to run coala, without asking feedback, and only showing the patches (without applying them). Reading the code..
I think it is

default_actions = *: ShowPatchAction

However, I get these messages:

....
[WARNING][11:18:07] Selected default action 'ShowPatchAction' for bear 'CPDBear' is not applicable. Action not applied.
[WARNING][11:18:07] Selected default action 'ShowPatchAction' for bear 'CPDBear' is not applicable. Action not applied.
[WARNING][11:18:07] Selected default action 'ShowPatchAction' for bear 'CPDBear' is not applicable. Action not applied.
[WARNING][11:18:07] Selected default action 'ShowPatchAction' for bear 'CPDBear' is not applicable. Action not applied.
....

Can I contribute in any place to support that in the CPD bear?

@sils
Copy link
Member Author

sils commented Nov 15, 2016

Hi,

CPDBear is not JavaPMDBear. PMD essentially ships with two tools, one does analysis and the other one copy and paste dedection (CPD).

I think none of them provide a way to automatically fix the issue. The default_actions setting is correct, we're planning on making "show the patch and show the results whenever a patch isn't available" the default behaviour for coala-ci for version 0.9 because it's quite a common thing.

@sils
Copy link
Member Author

sils commented Nov 15, 2016

I think if you were to "add support for showing patches for CPDBear" you'd probably be close to solving the halting problem ;P

@sils
Copy link
Member Author

sils commented Nov 15, 2016

Which OS are you on anyway?

@rpau
Copy link

rpau commented Nov 15, 2016

MacOS

Ok, so..definitely, what I would like to do is to run the JavaPMDBear, and get a list of the printed issues. How could I proceed?

Thanks a lot

@sils
Copy link
Member Author

sils commented Nov 15, 2016

So to get the list of issues, just run coala-ci, can you give the output of coala -I -V --bears JavaPMDBear --files "**.java" assuming you have java files in a pastebin?

@rpau
Copy link

rpau commented Nov 15, 2016

Hi,

Thanks a lot for the coala-ci.

The output of coala -I -V --bears JavaPMDBear --files "**.java"

[WARNING][11:48:18] Unable to collect bears from /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bears/java/JavaPMDBear.py. Probably the file is malformed or the module code raises an exception.
[DEBUG][11:48:18] Exception was:
Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/coalib/collecting/Collectors.py", line 125, in icollect_bears
    for bear in _import_bears(matching_file, kinds):

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/coalib/collecting/Collectors.py", line 27, in _import_bears
    types=list):

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/coalib/collecting/Importers.py", line 163, in iimport_objects
    attributes, local)

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/coala_utils/decorators.py", line 24, in yield_once_generator
    for item in iterator(*args, **kwargs):

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/coalib/collecting/Importers.py", line 122, in _iimport_objects
    module = _import_module(file_path)

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/coalib/collecting/Importers.py", line 31, in _import_module
    return __import__(module_name)

  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/bears/java/JavaPMDBear.py", line 5, in <module>
    from coala_utils.param_convertion import negate

ImportError: No module named 'coala_utils.param_convertion'
[WARNING][11:48:19] No bears were found matching 'JavaPMDBear'.
[DEBUG][11:48:19] Platform Darwin -- Python 3.5.2, pip 9.0.1, coalib 0.8.1
[DEBUG][11:48:19] Since the configuration settings have changed since the last run, the cache will be flushed and rebuilt.
[DEBUG][11:48:19] The file cache was successfully flushed.
Executing section Default...
[DEBUG][11:48:20] coala is run only on changed files, bears' log messages from previous runs may not appear. You may use the `--flush-cache` flag to see them.
[DEBUG][11:48:21] Files that will be checked:

@sils
Copy link
Member Author

sils commented Nov 15, 2016

Ok, to fix this do a pip install coala_utils==4.8 -U - did you by chance install a development version of coala or something that gave you a newer coala-utils version? If not we should be deeply worried that other users are affected too :/

@rpau
Copy link

rpau commented Nov 15, 2016

After that, which is 0.4.8

coala --show-bears --filter-by-language java
[ERROR][11:59:20] There is a conflict in the version of a dependency you have installed and the requirements of coala. This may be resolved by creating a separate virtual environment for coala or running `pip install coala-utils~=0.4.9`. Be aware that the latter solution might break other python packages that depend on the currently installed version.

However, after reinstalling 0.4.9 it shows the JavaPMDBear. It is a first step :-)
But now:

coala --files=src/main/java/\**.java --bears=JavaPMDBear -a --save
Executing section Default...
[WARNING][12:01:48] The bear JavaPMDBear does not fulfill all requirements. PMD is missing. Make sure to install it from <https://pmd.github.io/>
macbook:docker-java rpau$ brew install pmd
Warning: pmd-5.3.3 already installed

Another question (sorry if there are two much). There is a way to define a python component in the config to perform a given action when an issue is found (for example, to produce a report)? Or coala waits after everything is processed?

@sils
Copy link
Member Author

sils commented Nov 15, 2016

actions are indeed modular, ATM though you have to put them into the coala source code and you can't "link them in dynamically" because there has not been demand for that.

If you want to produce a report, I suggest running coala-json and produce the report from the JSON output.

@sils
Copy link
Member Author

sils commented Nov 15, 2016

Ok I found the issue, when installing PMD via brew it provides a pmd binary, on unix systems it provides a run.sh binary. This was already fixed for the CPD bear (same binary is used) because it's more popular. So this *is * actually a bug in that bear.

@rpau
Copy link

rpau commented Nov 15, 2016

Ok thanks a lot

@sils
Copy link
Member Author

sils commented Nov 15, 2016

I have a commit that should fix it, will push it within ~5mins. I hope we can merge it today so you can use the prerelease to get your stuff done!

sils added a commit that referenced this issue Nov 15, 2016
The binary differs. The very same change was already apploed to the
CPDBear but people often forget this one.

Fixes #998
sils added a commit that referenced this issue Nov 15, 2016
The binary differs. The very same change was already apploed to the
CPDBear but people often forget this one.

Fixes #998
@sils
Copy link
Member Author

sils commented Nov 15, 2016

See #999 - in case you want to help getting this merged, review comments are appreciated :)

sils added a commit that referenced this issue Nov 15, 2016
The binary differs. The very same change was already apploed to the
CPDBear but people often forget this one.

Fixes #998
sils added a commit that referenced this issue Nov 16, 2016
The binary differs. The very same change was already apploed to the
CPDBear but people often forget this one.

Fixes #998
gosom pushed a commit to gosom/coala-bears that referenced this issue Jul 15, 2017
The binary differs. The very same change was already apploed to the
CPDBear but people often forget this one.

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

No branches or pull requests

2 participants