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

The script is failing when collecting the pmd.sh metric on processed Java files #145

Closed
RuslanGaliullin opened this issue Dec 29, 2023 · 4 comments

Comments

@RuslanGaliullin
Copy link

RuslanGaliullin commented Dec 29, 2023

I want to collect CC and CoCo metrics for each method separately. I wrote my own filter which transforms into files of this kind:

class NewMvcRequestMatcher_equals_1 {public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        NewMvcRequestMatcher that = (NewMvcRequestMatcher) o;
        return Objects.equal(pattern, that.pattern) &&
                Objects.equal(method, that.method);
    }}

So files with no packages with only class ClassName_MethodName_Number { MethodDeclaration + MethodBody }.

For starting container change Dockerfile:

FROM yegor256/cam

ENV DEBIAN_FRONTEND=noninteractive

SHELL ["/bin/bash", "--login", "-c"]

RUN apt-get install openjdk-11-jdk -y
RUN java --version

RUN pip install aiofiles

WORKDIR /cam
COPY Makefile /cam
COPY requirements.txt /cam
COPY steps/install.sh /cam/steps/
COPY help/* /cam/help/
COPY tests/* /cam/tests/

RUN rm -rf /cam/metrics/multimetric.sh /cam/metrics/authors.sh /cam/metrics/jpeek.sh /cam/metrics/ast.py

COPY . /cam

But for vast majority of my processed method-files pmd.sh throws error. It occurs once and then fails for the rest files.

Failed to collect pmd.sh for /dataset/github/zhoutaoo/SpringCloud/auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/service/NewMvcRequestMatcher_equals_1.java

platform - Ubuntu 22.04

What could be the reason for this?

@RuslanGaliullin
Copy link
Author

RuslanGaliullin commented Dec 29, 2023

There might be strict requirements for the files for which the metric could be counted
It works absolutely fine for repo=yegor256/tojos

yegor256 added a commit that referenced this issue Jan 3, 2024
@yegor256
Copy link
Owner

yegor256 commented Jan 3, 2024

@RuslanGaliullin can you please show a large part of the log? I can't figure out why you only see this line, but don't see the error output of the pmd.sh:

Failed to collect pmd.sh for /dataset/github/zhoutaoo/SpringCloud/auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/service/NewMvcRequestMatcher_equals_1.java

@RuslanGaliullin
Copy link
Author

@yegor256, attaching more log. There is no error message, thats why it confused me, even in the first failure

4 scripts collected 9 metrics (sum=1525.327) for ResourceService_removeResource_1.java (345759/364784), in 5s
cyclomatic_complexity.py
Failed to collect pmd.sh for /dataset/github/zhoutaoo/SpringCloud/auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/config/BusConfig_resourceMessageConverter_9.java
cloc.sh
multimetric.sh
4 scripts collected 9 metrics (sum=1373.757) for BusConfig_resourceMessageConverter_9.java (345756/364784), in 5s
cyclomatic_complexity.py
Failed to collect pmd.sh for /dataset/github/zhoutaoo/SpringCloud/auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/service/NewMvcRequestMatcher_equals_1.java
cloc.sh
multimetric.sh
4 scripts collected 9 metrics (sum=4813.286) for NewMvcRequestMatcher_equals_1.java (345758/364784), in 6s
cyclomatic_complexity.py
Failed to collect pmd.sh for /dataset/github/zhoutaoo/SpringCloud/auth/authentication-server/src/main/java/com/springboot/cloud/auth/authentication/service/impl/GroupService_queryGroupsByUsername_0.java
cloc.sh
multimetric.sh
4 scripts collected 9 metrics

yegor256 added a commit that referenced this issue Jan 11, 2024
@yegor256
Copy link
Owner

@RuslanGaliullin the problem is the absence of pmd on your machine. Try make install first.

This was referenced Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants