Git Product home page Git Product logo

ck's People

Contributors

aaghamohammadi avatar alitaherinastooh avatar antoniosbarotsis avatar arraying avatar ayaankazerouni avatar boyang9602 avatar brenofariasdasilva avatar brentmeeusen avatar brunolsousa avatar dvanderleij avatar eriicf avatar georgemayko avatar jan-gerling avatar jeandersonbc avatar klerisson avatar leofernandesmo avatar lyrakisk avatar martinmladenov avatar mauricioaniche avatar maykon-oliveira avatar nolovedeepdev avatar oletraveler avatar samuelgrigolato avatar sedataset avatar tillwenke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ck's Issues

NOC request

Hi,
I am using your software and i'm finding it very usefull but for it to have actually all ck metrics it should have also NOC and your old version that had it doesn't analyze the inner classes so it's not usable in combo with the newer version. Could you maybe reimplement it in the newer version so that it also does it for inner classes?

Option to ignore Test classes

Hi,

Sometimes it is only necessary to refactor in the main part of your application, and the tests don't necessarily need to be refactored. It would be nice if there was an option to ignore test classes, and just produce the metrics for the main code. Is this possible?

check CBO type resolution in real example

Sometimes JDT is able to resolve the qualified name, sometimes it returns the simple name. My guess is that in our tests, we don't have folders for the packages. See if same thing happens in a real code.

Unique word counts the words from subclasses too

If a class contains a subclass, the number of unique words include the number of words in the subclasses too. That's not a wanted behaviour.

See test WordCountsTest#subclasses. The test is already there.

maxNestedBlocks should be named maxNestedBlocksQty for consistency

I just noticed by accident that there is maxNestedBlocks for method level while its class counterpart is maxNestedBlocksQty.

"numbersQty", "assignmentsQty", "mathOperationsQty", "variablesQty", "maxNestedBlocksQty",
"anonymousClassesQty", "innerClassesQty", "lambdasQty", "uniqueWordsQty", "modifiers", "logStatementsQty" };
private static final String[] METHOD_HEADER = { "file", "class", "method", "constructor", "line", "cbo", "wmc", "rfc", "loc",
"returnsQty", "variablesQty", "parametersQty", "methodsInvokedQty", "methodsInvokedLocalQty", "methodsInvokedIndirectLocalQty", "loopQty", "comparisonsQty", "tryCatchQty",
"parenthesizedExpsQty", "stringLiteralsQty", "numbersQty", "assignmentsQty", "mathOperationsQty",
"maxNestedBlocks", "anonymousClassesQty", "innerClassesQty", "lambdasQty", "uniqueWordsQty", "modifiers", "logStatementsQty", "hasJavaDoc" };

IMO the suffix Qty should be added for consistency as the other metrics.

Program ends when ASTParser cannot parse Java files

Sometimes AST cannot be parsed (due to file with syntax error/ new syntax, given by new Java version).
If it is the case, the program crashes and methods.csv is empty:

If I set max partitions to 1, it didn't help. Setting JLS14 didn't help.

Exception in thread "main" java.lang.NullPointerException
	at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getPackage0(PackageBinding.java:176)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.createPlainPackage(LookupEnvironment.java:1126)
	at org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:135)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:475)
	at org.eclipse.jdt.internal.compiler.Compiler.accept(Compiler.java:340)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.accept(CompilationUnitResolver.java:186)
	at org.eclipse.jdt.internal.compiler.lookup.LookupEnvironment.askForType(LookupEnvironment.java:334)
	at org.eclipse.jdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:276)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:3464)
	at org.eclipse.jdt.internal.compiler.lookup.Scope.getType(Scope.java:3175)
	at org.eclipse.jdt.internal.compiler.ast.SingleTypeReference.getTypeBinding(SingleTypeReference.java:57)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.internalResolveType(TypeReference.java:536)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:638)
	at org.eclipse.jdt.internal.compiler.ast.TypeReference.resolveType(TypeReference.java:634)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:293)
	at org.eclipse.jdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:270)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:664)
	at org.eclipse.jdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:361)
	at org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:573)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1490)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.resolve(TypeDeclaration.java:1615)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:662)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:902)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1044)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:662)
	at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1001)
	at com.github.mauricioaniche.ck.CK.calculate(CK.java:109)
	at com.github.mauricioaniche.ck.CK.calculate(CK.java:59)
	at com.github.mauricioaniche.ck.Runner.main(Runner.java:34)

Could you please handle the exception and continue the flow (the bad file will be just ignored and not included into csv)?
And if partitions are set to some value (not 1), you should ignore only 1 file, not the whole partition

A coupling metric that only counts classes which the base class invokes a method

Hello,

I find a conflict between your implementation of CBO and the definition of the original CK paper. In the paper, authors say "CBO for a class is a count of the number of other classes to which it is coupled where two classes are coupled if methods declared in one class use methods or instance variables defined by the other class."

Problem running

When try to use standalone version with command:

java -jar ck-x.x.x-SNAPSHOT-jar-with-dependencies.jar <project dir>

The program returns the following message:

log4j:WARN No appenders could be found for logger (com.github.mauricioaniche.ck.CK).
log4j:WARN Please initialize the log4j system properly.

Error writing the CSV file containing the class metrics

Hello,

There seems to be an issue with writing the metrics for class results in the file https://github.com/mauricioaniche/ck/blob/master/src/main/java/com/github/mauricioaniche/ck/ResultWriter.java. Some values are shifted. For example, result.getVisibleMethods().size() is written where abstractMethodsQty should be, abstractMethodsQty is written where finalMethodsQty should be and so on. The majority of metrics are ok; this affects just the abstract method quantity and the fields' numbers.

This is what the CSV row should look like according to the header:

private static final String[] CLASS_HEADER = { "file", "class", "type", "cbo", "wmc", "dit", "rfc", "lcom", "tcc", "lcc", "totalMethodsQty", "staticMethodsQty", "publicMethodsQty", "privateMethodsQty", "protectedMethodsQty", defaultMethodsQty", "abstractMethodsQty", "finalMethodsQty", "synchronizedMethodsQty", "totalFieldsQty", "staticFieldsQty", "publicFieldsQty", "privateFieldsQty", "protectedFieldsQty", "defaultFieldsQty", "visibleFieldsQty", "finalFieldsQty", "synchronizedFieldsQty", "nosi", "loc", "returnQty", "loopQty", "comparisonsQty", "tryCatchQty", "parenthesizedExpsQty", "stringLiteralsQty", "numbersQty", "assignmentsQty", "mathOperationsQty", "variablesQty", "maxNestedBlocksQty", "anonymousClassesQty", "innerClassesQty", "lambdasQty", "uniqueWordsQty", "modifiers", "logStatementsQty" };

and this is the actual row (differences are bolded):

this.classPrinter.printRecord(result.getFile(), result.getClassName(), result.getType(), result.getCbo(), result.getWmc(),
result.getDit(), result.getRfc(), result.getLcom(), result.getTightClassCohesion(), result.getLooseClassCohesion(),
result.getNumberOfMethods(), result.getNumberOfStaticMethods(), result.getNumberOfPublicMethods(),
result.getNumberOfPrivateMethods(), result.getNumberOfProtectedMethods(),
result.getNumberOfDefaultMethods(), result.getVisibleMethods().size(), result.getNumberOfAbstractMethods(),
result.getNumberOfFinalMethods(), result.getNumberOfSynchronizedMethods(), result.getNumberOfFields(),
result.getNumberOfStaticFields(), result.getNumberOfPublicFields(), result.getNumberOfPrivateFields(),
result.getNumberOfProtectedFields(), result.getNumberOfDefaultFields()
, result.getNumberOfFinalFields(),
result.getNumberOfSynchronizedFields(), result.getNosi(), result.getLoc(), result.getReturnQty(),
result.getLoopQty(), result.getComparisonsQty(), result.getTryCatchQty(),
result.getParenthesizedExpsQty(), result.getStringLiteralsQty(), result.getNumbersQty(),
result.getAssignmentsQty(), result.getMathOperationsQty(), result.getVariablesQty(),
result.getMaxNestedBlocks(), result.getAnonymousClassesQty(), result.getInnerClassesQty(),
result.getLambdasQty(), result.getUniqueWordsQty(), result.getModifiers(), result.getNumberOfLogStatements());

Better names to anonymous classes

Take the example of this real-world class: HectorPolicyManagerImpl, also in our repo.

The method getAllPolicies declares an anonymous class in line 113. CK calls it net.retakethe.policyauction.data.impl.HectorPolicyManagerImpl$Anonymous1.

That's too generic. Maybe a better name would be net.retakethe.policyauction.data.impl.HectorPolicyManagerImpl.getAllPolicies.filter$Anonymous1.

How to get methods of inner classes in a class

Hi,

I am using this library for research and I need to find the method-level metrics, so I am traversing the CKClassResult by using getMethods function to find the metric values of desired methods, but I have found that this method does not return methods that are inside of an inner class. Is there any way to get those methods?

Thanks

Java language support table/matrix

I was not able to find a Java version support table for your library, does it exist somewhere? If not, maybe it would be nice to have such information in your README.md.

failed test: 2

Failed tests:
NOCTest.should_detect_children:28 expected:<1> but was:<0>

java.lang.ArrayIndexOutOfBoundsException: 3000

Hello, I am using your tool for my project. While running it on the repository https://github.com/eclipse/eclipse-collections, commit “617cd8e” I got “Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3000”

git clone -b master --single-branch https://github.com/eclipse/eclipse-collections
git checkout -f 617cd8e

And run ck program for that repository snapshot

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3000
	at org.eclipse.jdt.internal.compiler.ClassFile.generateBootstrapMethods(ClassFile.java:2965)
	at org.eclipse.jdt.internal.compiler.ClassFile.addAttributes(ClassFile.java:387)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:577)
	at org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.generateCode(TypeDeclaration.java:635)
	at org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration.generateCode(CompilationUnitDeclaration.java:368)
	at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:781)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:1005)
	at org.eclipse.jdt.core.dom.CompilationUnitResolver.resolve(CompilationUnitResolver.java:636)
	at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:990)
	at com.github.mauricioaniche.ck.CK.calculate(CK.java:82)
	at com.github.mauricioaniche.ck.Runner.main(Runner.java:18)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Exceptions a method throws

We can add information related to exceptions:

  • How many exception are thrown
  • How many checked exceptions are thrown

Cannot access CK bad class file

Hi all

Firstly, many thanks for this powerful tool that helps us in our researches.
I tried to add Gradle dependency to my Java implementation to use this library. I got this issue when I tried to build the project.

I tried many solutions and I gave up. Can you please help me to solve it?

I used intellij IDM, Java 1.8 and javac 1.8.0_201.

Thanks,

cannot access CK bad class file: C:\Users\GIGABYTE.gradle\caches\modules-2\files-2.1\com.github.mauricioaniche\ck\0.4.3\3363cb42f4417452fe749730dc813f68c658a840\ck-0.4.3.jar(com/github/mauricioaniche/ck/CK.class) class file has wrong version 55.0, should be 52.0 Please remove or make sure it appears in the correct subdirectory of the classpath.

Method identifiers have commas, throwing off CSV parser

I've been playing with this a little bit this week. In the method.csv that is output, the method identifiers look something like this:

getValue/3[int[],int[],String], which I guess maps to name/#params[param1,param2,param3]. This is good because, along with the class attribute, this gives you a unique identifier for the method.

However, the commas inside the square brackets are likely to throw off CSV parsers. Specifically, it looks to pandas like there are more values than fields in the line with the "extra" commas. I have confirmed that neither pandas nor R are able to read the file.

This can be dealt with with some file processing, but I think it would be better to output an "analysis-ready" file. Would you be open to a PR that changes those commas to some other character, say semi-colons?

WMC for conditional statements

Hello,

I think there is a problem in calculating the WMC metric based on cyclomatic complexity.
For example, consider the following methods:

public class CC6 {
    public boolean m1(int a) {
        if (0 <= a && a <= 10) {
            return true;
        }
        return false;
    }

    public boolean m2(int a) {
        boolean cond = (0 <= a && a <= 10);
        if (cond) {
            return true;
        }
        return false;
    }

    public boolean m3(int a) {
        if (0 <= a <= 10) {
            return true;
        }
        return false;
    }
}

All these three methods do the same thing. However, the WMC complexities for m1,m2, and m3 are 3,2, and 2 respectively. In fact, the following inline conditional statement

boolean cond = (0 <= a && a <= 10);

does not increase CC complexity at all. Furthermore, when a condition becomes compact such as

if (0 <= a <= 10)

you increase CC complexity just by one. I know the original paper does not take into account situations like that. However, don't you think it would be better to consider that?

code smell fix

I identified some bad code smells in your project, I would like to help.

Standalone Version Build Error

Hi, there seems to be an error preventing the build from succeeding. This is the error when running "mvn clean compile package"
image

Pulling from ck-master. I have tried the same with release tags 0.6.3 and 0.6.4 and ran into the same error.

Thank you.

Regards,
Alvin

Counting default fields

Investigating the output of one experiment I found one weird behavior.
A class that has 36 fields, but with 0 public, private, protected and default fields.
I debugged and I found that all the fields were default, but the condition isDefault failed for all of them.

I'm not an expert in JDT, so I don't know how to fix. I also added a new test case to ensure that the number of fields is equal to the sum of private, public, protected and default fields.

File analyzed

Output:

  • 36 fields
    • 0 public
    • 0 private
    • 0 default
    • 0 protected

Add all endVisit() callbacks in CKVisitor

CKVisitor is the one that JDT invokes whenever it visits a Node. CKVisitor then calls the visits inside each of the metrics. So, CKVisitor should propagate all calls to visitX() or endVisitX(), in the metrics.

It's a boring copy-and-paste task, but we need to add all of them for the endVisits() as we still miss some. I have been adding them on-demand (i.e., whenever a metric needs it, I add it). Of course, it always takes me 15 minutes to notice that a bug that is caused simply because the method is not being called.

Travis CI Build Failure

This Travis CI build fails with the following error:

[ERROR] /home/travis/build/AntoniosBarotsis/ck/src/main/java/com/github/mauricioaniche/ck/CK.java:[105,63] cannot access org.eclipse.core.runtime.Plugin
  bad class file: /home/travis/.m2/repository/org/eclipse/platform/org.eclipse.core.runtime/3.24.0/org.eclipse.core.runtime-3.24.0.jar(org/eclipse/core/runtime/Plugin.class)
    class file has wrong version 55.0, should be 52.0
    Please remove or make sure it appears in the correct subdirectory of the classpath.

Raw logs can be found here.

This fails due to the project using Java 8, switching the version to 11 or above fixes the issue. I was personally using a higher version and did not notice the build failure.

I can't find information on the Maven repository or their website on which version of Java each version was compiled with.

problem with execution

Exception in thread "main" java.lang.NullPointerExceptionat com.github.mauricioaniche.ck.FileUtils.getAllDirs(FileUtils.java:23)
at com.github.mauricioaniche.ck.FileUtils.getAllDirs(FileUtils.java:11)
at com.github.mauricioaniche.ck.CK.calculate(CK.java:52)
at com.github.mauricioaniche.ck.Runner.main(Runner.java:18)

Build of fresh clone fails due to failing test

I am running mvn clean package on HEAD 17b80cb which fails due to a failing test.

-------------------------------------------------------------------------------
Test set: com.github.mauricioaniche.ck.NOCTest
-------------------------------------------------------------------------------
Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.012 s <<< FAILURE! - in com.github.mauricioaniche.ck.NOCTest
shouldDetectChildren  Time elapsed: 0.009 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <1> but was: <2>
	at com.github.mauricioaniche.ck.NOCTest.shouldDetectChildren(NOCTest.java:19)

This happens on both a JDK11 and JDK16 Maven runner. Similarly, if I run the tests through IntelliJ, this is the only test that fails.

A new CC metric that takes nesting into account

By definition, the CC metric does not take into account the nesting levels of the method. For example, consider the following Python source code:

public int getPayAmount() {
  int result = 0;
  if (isDead)
    result = deadAmount();
  else {
    if (isSeparated)
      result = separatedAmount();
    else {
      if (isRetired)
        result = retiredAmount();
      else
        result = normalPayAmount();
    }
  }
  return result;
}

By refactoring this code, we get:

public void getPayAmount() {
  if (isDead) return deadAmount();
  if (isSeparated) return separatedAmount();
  if (isRetired) return retiredAmount();
  return normalPayAmount();
}

As you can see, By applying a popular technique named Replace Nested Conditional with Guard Clauses, the source code structure would improve a lot. However, the CC metric does not change (by definition).
Some researchers have proposed a few solutions. Surprisingly, the best solution (in my opinion) has the minimum citation link .

(Help wanted!) More and more tests!

CK is a simple tool; yet, people's code are complicated!! Although our test suite has been growing, there are always exceptional cases that might lead the tool to bring strange results.

If you are looking for a way to start contributing to this project, I suggest you to write tests!! Our test suite is full of examples! In practice, all you need to do is:

  • Create a "fake" class with the property you want to assert, e.g., does CK calculate WMC well when we have a ternary if in the code? This code goes to the /fixture folder
  • Feel free to either add your test to an existing one (e.g., if you are adding one more test for the WMC metric, this method should be in the WMCTest class) or add a new file (e.g., you are testing a more holistic behaviour, and this behaviour does not depend on a single metric)
  • Write a test that executes CK in the folder that contains your fixture.
  • Write good assertions! Try to assert as much as possible. Good assertions are key! A good one to remember is to assert the value of that metric at class and method level (we have found bugs where the metric at method-level was correct, but at class-level, there was a bug)!

Submit your tests as a PR!

If you found a bug,** THANK YOU**! Feel free to fix it yourself! If you can't, no worries. Just open an issue, and I'll work on that!

Requesting an official explanation for code metrics

I really like the code metric analysis tool developed by your team, which is both lightweight and efficient. However, during the process of statistical analysis of code metrics, I didn't quite understand some of the metrics, and I tried to search for related documents, but failed. They are:

method-level

  • cbo
  • cboModified
  • wmc
  • rfc

Remove duplicated field (ResultWriter)

I noticed that methods.csv generates startLine and line with the same values... Looking closer to the source file, I noticed the duplicate call to method.getStartLine().

Incorrect CBO for Generic Classes

Suppose we have a generic class Box. The CBO returns 2 for the following class:

public class Coupling6 {
    private Box<Integer> integerBox = new Box<Integer>();
}

However, I think it should return one.

Invalid environment settings

Sometimes, running CK will cause:

Exception in thread "main" java.lang.IllegalStateException: invalid environment settings
        at org.eclipse.jdt.core.dom.ASTParser.getClasspath(ASTParser.java:259)
        at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1001)
        at com.github.mauricioaniche.ck.CK.calculate(CK.java:113)
        at com.github.mauricioaniche.ck.CK.calculate(CK.java:62)
        at com.github.mauricioaniche.ck.Runner.main(Runner.java:43)

For the cause of this, see this reply

Original Issue, hidden by default

Sometimes, running CK will cause:

Exception in thread "main" java.lang.IllegalStateException: invalid environment settings
        at org.eclipse.jdt.core.dom.ASTParser.getClasspath(ASTParser.java:259)
        at org.eclipse.jdt.core.dom.ASTParser.createASTs(ASTParser.java:1001)
        at com.github.mauricioaniche.ck.CK.calculate(CK.java:113)
        at com.github.mauricioaniche.ck.CK.calculate(CK.java:62)
        at com.github.mauricioaniche.ck.Runner.main(Runner.java:43)

This occurs arbitrarily, it was working on my machine, now it does not. A groupmate tried the exact same script on his laptop, where it worked, but it did not work on his desktop.

We run the following inside our repository/metrics folder:

java -jar ck.jar ../ false 0 false ./output/

This is run on java version "11.0.6" 2020-01-14 LTS.

Inside of CK#calculate(Path, CKNotifier, Path...) the paths to the .java files are all correct. There are no files there that should not be there.

Curiously enough, ASTParser is not 1000+ lines so the stacktrace is hard to follow. The method looks as such:

        Main main = new Main(new PrintWriter(System.out), new PrintWriter(System.err), false, (Map)null, (CompilationProgress)null);
        ArrayList allClasspaths = new ArrayList();

        try {
            if ((this.bits & 32) != 0) {
                Util.collectRunningVMBootclasspath(allClasspaths);
            }

            int i;
            int max;
            if (this.sourcepaths != null) {
                i = 0;

                for(max = this.sourcepaths.length; i < max; ++i) {
                    String encoding = this.sourcepathsEncodings == null ? null : this.sourcepathsEncodings[i];
                    main.processPathEntries(4, allClasspaths, this.sourcepaths[i], encoding, true, false);
                }
            }

            if (this.classpaths != null) {
                i = 0;

                for(max = this.classpaths.length; i < max; ++i) {
                    main.processPathEntries(4, allClasspaths, this.classpaths[i], (String)null, false, false);
                }
            }

            ArrayList pendingErrors = main.pendingErrors;
            if (pendingErrors != null && pendingErrors.size() != 0) {
                throw new IllegalStateException("invalid environment settings");
            } else {
                return allClasspaths;
            }
        } catch (IllegalArgumentException var6) {
            throw new IllegalStateException("invalid environment settings", var6);
        }

It seems that pendingErrors is causing the problem, but the exception is supremely unhelpful and I have no idea what is going wrong. I have tried updating JDT but I cannot even find where it is released, their JavaDoc for the version I need is as good as non-existent.

If anyone has faced this problem before and knows how to resolve it, please let me know. Otherwise, I will continue to look into it.

Rename 'subclass' to 'innerclass'

What CK actually calculates in the subclass is the number of inner classes a class has.

We should:

  • Rename the metric class
  • Rename the tests
  • Rename the column in the output

This introduces breaking changes, but they are for the good.

Pass JARs as context to JDT

As an optional parameter, the user might decide to use the jars in the directory of the project as a source for JDT to do better binding resolving.

Suggestion: pass a boolean. If true, CK scans the directory of the project, and feeds all JAR files to JDT.

Support multiple static initializers

There can be more than one static initialiser in a class. Right now, CK understands both, but gives them the same name: "(initializer)". It should give different names, e.g., (initializer 1), (initializer 2), ...

CK not finding classes

CK does not find classes if the folder structure is as follows: ambry/ambry-messageformat/src/main/java/com.github.ambry.messageformat/.
I noticed this bug during the data-collection where it occurred quite frequently.

Example Projects

1
2
3

Some Logs

/data-collection_worker_1 2020-05-19 06:56:04 ERROR RefactoringAnalyzer:242 CK did not find class com.github.ambry.messageformat.MessageFormatSend/null
{refactoring: Change Variable Type	headerFormat : MessageFormat.MessageHeader_Format_V1 to headerFormat : MessageFormatRecord.MessageHeader_Format_V1 in method private calculateOffsets() : void in class com.github.ambry.messageformat.MessageFormatSend commit: c612f30db3f4c49f2b302417725456c6005f1060 from project: Project{id=1409, datasetName='github', gitUrl='https://github.com/linkedin/ambry', projectName='ambry', dateOfProcessing=java.util.GregorianCalendar[time=1589871161821,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2020,MONTH=4,WEEK_OF_YEAR=21,WEEK_OF_MONTH=4,DAY_OF_MONTH=19,DAY_OF_YEAR=140,DAY_OF_WEEK=3,DAY_OF_WEEK_IN_MONTH=3,AM_PM=0,HOUR=6,HOUR_OF_DAY=6,MINUTE=52,SECOND=41,MILLISECOND=821,ZONE_OFFSET=0,DST_OFFSET=0]', finishedDate=null', commits=2735', commitCountThresholds=[15, 20, 25, 30, 35, 40, 45, 50]', javaLoc=155896', numberOfProductionFiles=622', numberOfTestFiles=328', productionLoc=74200', testLoc=81696', exceptionsCount=0', lastCommitHash=36b2d5b6aa4265ec3a7b450dc633059160ac68d3', isInconsistent=false'}

/data-collection_worker_5 2020-05-18 18:23:03 ERROR RefactoringAnalyzer:242 CK did not find class im.actor.model.network.mtp.AuthIdRetriever.requestAuthId.createConnection/null
{refactoring: Change Variable Type	bis : ByteArrayInputStream to dataInput : DataInput in method public onMessage(data byte[], offset int, len int) : void in class im.actor.model.network.mtp.AuthIdRetriever.requestAuthId.createConnection commit: 8c859310a55ddb057714514fb545a28037d86cc8 from project: Project{id=388, datasetName='github', gitUrl='https://github.com/actorapp/actor-platform', projectName='actor-platform', dateOfProcessing=java.util.GregorianCalendar[time=1589826144296,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2020,MONTH=4,WEEK_OF_YEAR=21,WEEK_OF_MONTH=4,DAY_OF_MONTH=18,DAY_OF_YEAR=139,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=6,HOUR_OF_DAY=18,MINUTE=22,SECOND=24,MILLISECOND=296,ZONE_OFFSET=0,DST_OFFSET=0]', finishedDate=null', commits=8308', commitCountThresholds=[15, 20, 25, 30, 35, 40, 45, 50]', javaLoc=156980', numberOfProductionFiles=2218', numberOfTestFiles=14', productionLoc=156095', testLoc=885', exceptionsCount=0', lastCommitHash=5123c1584757c6eeea0ed2a0e7e043629871a0c6', isInconsistent=false'}

/data-collection_worker_21 2020-05-18 13:21:05 ERROR RefactoringAnalyzer:242 CK did not find class com.example.android.persistence.ui.ProductAdapter.setProductList.result.calculateDiff/null
{refactoring: Rename Variable	old : Product to oldProduct : Product in method public areContentsTheSame(oldItemPosition int, newItemPosition int) : boolean in class com.example.android.persistence.ui.ProductAdapter.setProductList.result.calculateDiff commit: e64d25eca8e1fa218344e769c4aedfa995002ffd from project: Project{id=51, datasetName='github', gitUrl='https://github.com/googlesamples/android-architecture-components', projectName='android-architecture-components', dateOfProcessing=java.util.GregorianCalendar[time=1589808063556,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=sun.util.calendar.ZoneInfo[id="Etc/UTC",offset=0,dstSavings=0,useDaylight=false,transitions=0,lastRule=null],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2020,MONTH=4,WEEK_OF_YEAR=21,WEEK_OF_MONTH=4,DAY_OF_MONTH=18,DAY_OF_YEAR=139,DAY_OF_WEEK=2,DAY_OF_WEEK_IN_MONTH=3,AM_PM=1,HOUR=1,HOUR_OF_DAY=13,MINUTE=21,SECOND=3,MILLISECOND=556,ZONE_OFFSET=0,DST_OFFSET=0]', finishedDate=null', commits=458', commitCountThresholds=[15, 20, 25, 30, 35, 40, 45, 50]', javaLoc=4028', numberOfProductionFiles=63', numberOfTestFiles=26', productionLoc=2603', testLoc=1425', exceptionsCount=0', lastCommitHash=f1ec5c2f75ed2a9663f627874142942cdaec2262', isInconsistent=false'}

New version(0.5.0) not working with maven plugin (delete pitest-maven as dependency )

The pitest-maven dependency has been added in version 0.5.0 (line 107 in the pom), it's a plugin and not a library.

<dependency>
      <groupId>org.pitest</groupId>
      <artifactId>pitest-maven</artifactId>
      <version>1.4.11</version>
</dependency>

I tryed to use the new version 0.6.2 with my maven plugin for CK, but it's not possible to compile anymore, because pitest-maven uses old maven libraries. ERROR : The API of the mojo scanner is not compatible with this plugin version.

I think it's very important to remove this dependency(too many sub-dependencies), but not the plugin, pitest is very cool to validate the tests.

Nested Blocks return 0 for enhanced forEach populated with lambda function

Hi @mauricioaniche
I am writing tests for NumberOfMaxNestedBlock.java . I have come accross the following issue:

class NestedBlocks8 {
        public void m1() {
        List<Integer> integers = Arrays.asList(3, 9, 7, 6, 10, 20);
        integers.forEach(i -> System.out.println(50 / i));
    }
}

I expect that the max depth of m1() equals one. However, the getMaxNestedBlocks() returns zero. Indeed, It happens when the enhanced version of For along with a lambda function is employed.

test failure

Failed tests:
NOCTest.should_detect_children:26 expected:<2> but was:<0>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.