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

Kotlin plugin #111

Merged
merged 9 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/main/java/io/jenkins/plugins/analysis/warnings/Kotlin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package io.jenkins.plugins.analysis.warnings;

import edu.hm.hafner.analysis.IssueParser;
import edu.hm.hafner.analysis.parser.JavacParser;
import edu.umd.cs.findbugs.annotations.NonNull;
import hudson.Extension;
import io.jenkins.plugins.analysis.core.model.ReportScanningTool;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
* Provides a parser and customized messages for Kotlin errors and warnings.
*
* @author Sladyn Nunes
*/
public class Kotlin extends ReportScanningTool {
private static final long serialVersionUID = 2618843071479627178L; // To be added
private static final String ID = "kotlin";

/**
* Creates a new instance of {@link Kotlin}.
*/
@DataBoundConstructor
public Kotlin() {
super();
// empty constructor required for stapler
}

@Override
public IssueParser createParser() {
return new JavacParser();
}

/**
* Descriptor for this static analysis tool.
*/
@Symbol("kotlin")
@Extension
public static class Descriptor extends ReportScanningToolDescriptor {
/**
* Creates the descriptor instance.
*/
public Descriptor() {
super(ID);
}

@NonNull
@Override
public String getDisplayName() {
return Messages.Warnings_Kotlin_ParserName();
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there an icon available that can be included in the warnings-plugin? (Check License).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not think we can use the android one, so NO

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Warnings.Cargo.ParserName=Cargo
Warnings.AcuCobol.ParserName=AcuCobol Compiler
Warnings.JavaParser.ParserName=Java
Warnings.JavaDoc.ParserName=JavaDoc
Warnings.Kotlin.ParserName=Kotlin
Warnings.EclipseParser.ParserName=Eclipse ECJ
Warnings.Taglist.ParserName=Maven Taglist Plugin
Warnings.Maven.ParserName=Maven
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,17 @@ public void shouldFindAllJavaIssues() {
shouldFindIssuesOfTool(2 + 1 + 1 + 2, new Java(), "javac.txt", "gradle.java.log", "ant-javac.txt", "hpi.txt");
}

/** Runs the CssLint parser on an output file that contains 51 issues. */
/**
* Runs the Kotlin parser on several output files that contain 4 issues.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contains 1 issue

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where do I upload the logo and do we want only a logo or a log and text with it ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logos are in https://github.com/jenkinsci/warnings-ng-plugin/tree/master/src/main/webapp/icons. Please add a line that references the license somehow in the License.txt file.

You can have a look at the https://github.com/jenkinsci/warnings-ng-plugin/blob/master/src/main/java/io/jenkins/plugins/analysis/warnings/AndroidLint.java to see how icons are used.

If everything is working correctly you will see the result in https://github.com/jenkinsci/warnings-ng-plugin/blob/master/SUPPORTED-FORMATS.md (after running the ToolLister).

*/
@Test
public void shouldFindAllKotlinIssues() {
shouldFindIssuesOfTool(1, new Kotlin(), "kotlin.txt");
}

/**
* Runs the CssLint parser on an output file that contains 51 issues.
*/
@Test
public void shouldFindAllCssLintIssues() {
shouldFindIssuesOfTool(51, new CssLint(), "csslint.xml");
Expand Down
45 changes: 45 additions & 0 deletions src/test/resources/io/jenkins/plugins/analysis/warnings/kotlin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[INFO] Scanning for projects...
[INFO]
[INFO] ----------< com.michaelrice.kotlin:hello-world-maven-example >----------
[INFO] Building hello-world-maven-example 1.0
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ hello-world-maven-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/hafner/Development/git/kotlin-maven-hello-world/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ hello-world-maven-example ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- kotlin-maven-plugin:1.1.2:compile (compile) @ hello-world-maven-example ---
[INFO] Kotlin Compiler version 1.1.2
[INFO] Compiling Kotlin sources from [/Users/hafner/Development/git/kotlin-maven-hello-world/src/main/kotlin]
[INFO] Module name is hello-world-maven-example
[WARNING] /Users/hafner/Development/git/kotlin-maven-hello-world/src/main/kotlin/hello.kt: (4, 11) Parameter 'args' is never used
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ hello-world-maven-example ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /Users/hafner/Development/git/kotlin-maven-hello-world/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ hello-world-maven-example ---
[INFO] No sources to compile
[INFO]
[INFO] --- kotlin-maven-plugin:1.1.2:test-compile (test-compile) @ hello-world-maven-example ---
[INFO] Kotlin Compiler version 1.1.2
[WARNING] No sources found skipping Kotlin compile
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ hello-world-maven-example ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ hello-world-maven-example ---
[INFO] Building jar: /Users/hafner/Development/git/kotlin-maven-hello-world/target/hello-world-maven-example-1.0.jar
[INFO]
[INFO] --- maven-assembly-plugin:2.6:single (make-assembly) @ hello-world-maven-example ---
[INFO] Building jar: /Users/hafner/Development/git/kotlin-maven-hello-world/target/hello-world-maven-example-1.0-jar-with-dependencies.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.100 s
[INFO] Finished at: 2019-06-12T21:47:44+02:00
[INFO] ------------------------------------------------------------------------
~/D/g/kotlin-maven-hello-world (master|✚1) $