yegor256 / cam

Classes and Metriсs (CaM): a dataset of Java classes from public open-source GitHub repositories
http://cam.yegor256.com
MIT License
23 stars 34 forks source link

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

Closed RuslanGaliullin closed 8 months ago

RuslanGaliullin commented 9 months ago

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 commented 9 months ago

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

yegor256 commented 8 months ago

@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 commented 8 months ago

@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 commented 8 months ago

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