Skip to content

Commit

Permalink
Merge pull request #3 from Sagacify/staging
Browse files Browse the repository at this point in the history
Add scoverage metrics and reports
  • Loading branch information
Augustin Borsu committed May 1, 2016
2 parents 5adef59 + 371cfc8 commit 5ece71d
Show file tree
Hide file tree
Showing 57 changed files with 3,156 additions and 11 deletions.
26 changes: 21 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ Intended for sonarqube 5.4
Download the latest relase into your sonar extentions/downloads folder.
Restart sonarqube either using the update center or manually.

The rules in scalastyle are almost all deactivated. They must be activated and either make scala rules inherit scalastyle rules or change the project's rules.

For more information about either scalastyle rules or scoverage results please consult their upstream documentation first:

* [NCR-CoDE/sonar-scalastyle](https://github.com/NCR-CoDE/sonar-scalastyle)
* [RadoBuransky/sonar-scoverage-plugin](https://github.com/RadoBuransky/sonar-scoverage-plugin)

# Build from source
```mvn package```

Expand All @@ -16,16 +23,23 @@ mvn test
sonar-runner -D sonar.projectKey=Sagacify:sonar-scala
```

# Contributing
Contributions wre accepted in the form of a pull request or a signed patch.
Please follow the semantic changelog to format your commits [cfr]((https://github.com/Sagacify/komitet-gita-bezopasnosti).
All changes are submitted to automated tests that must pass for the pull-request to be merged.

# Info
This plugin is not an evolution from the legacy sonar-scala-plugin of which versions can be found laying around such as [1and1/sonar-scala](https://github.com/1and1/sonar-scala).
The previous plugin used the scala compiler to create its metrics which had the disadvantage of requiring a specific plugin per scala version.
Instead, we are using the [scala-ide/scalariform](https://github.com/scala-ide/scalariform) library to parse the source code in a version independent way.

# TODO
# TODO (by priority)
* Add property to sepcify scala version (currently defaults to 2.11.8)
* Integrate scalastyle
* Integrate coverage metrics
* Integrate scalawarts
* Add Complexity metric on file (use the one in scalastyle)
* remove dependency on commons-io (Currently only needed by BruteForceSequenceMatcher)
* Uncomment ScoverageSensorSpec
* Integrate other java compatible code quality tools
* Optimize sensors i.e. (scalastyle and base both read and parse source files.)
...

# Credits
Expand All @@ -40,5 +54,7 @@ Here is a list of the main ones.

[NCR-CoDE/sonar-scalastyle](https://github.com/NCR-CoDE/sonar-scalastyle)

[RadoBuransky/sonar-scoverage-plugin](https://github.com/RadoBuransky/sonar-scoverage-plugin)

# Integration
Sonar-scala integrates the latest code from the [Sonar Scalastyle Plugin](https://github.com/NCR-CoDE/sonar-scalastyle) directly. All thise files must keep their original license. Also their history was pulled along with them. Any further change upstream should be incorporated using cherry-picks or merges.
For ease of use, Sonar Scala directly integrates the latest code from the [Sonar Scalastyle Plugin](https://github.com/NCR-CoDE/sonar-scalastyle) and [Sonar Scoverage Plugin](https://github.com/RadoBuransky/sonar-scoverage-plugin). This is possible as all three projects are released under the LGPL3 license. Nevertheless, all merged files are to keep their original copyright, classpath, and commit history. Any further change upstream should be incorporated using cherry-picks or merges.
21 changes: 20 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<artifactId>sonar-scala-plugin</artifactId>
<packaging>sonar-plugin</packaging>
<version>0.0.2-SNAPSHOT</version>
<version>0.0.3-SNAPSHOT</version>

<name>Sonar Scala Plugin</name>
<description>Enables analysis of Scala projects into Sonar.</description>
Expand Down Expand Up @@ -92,6 +92,18 @@
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.0</version>
</dependency>

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.5</version>
</dependency>

<!-- unit tests -->
<dependency>
<groupId>org.scalatest</groupId>
Expand Down Expand Up @@ -133,7 +145,14 @@
</dependencies>

<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<plugins>
<plugin>
<groupId>org.scoverage</groupId>
<artifactId>scoverage-maven-plugin</artifactId>
<version>1.1.1</version>
</plugin>

<!-- disable surefire -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
32 changes: 32 additions & 0 deletions samples/maven/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
*.class
*.log

# Package files
*.war
*.jar
*.ear

# Maven
out/
target/

# Eclipse
.project
.classpath
.settings/

# IDEA
*.iml
.idea

# OSX
.DS_STORE
.Trashes

# Windows
Desktop.ini
Thumbs.db

# Python
*.pyc

3 changes: 3 additions & 0 deletions samples/maven/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Run with:

`mvn clean scoverage:report sonar:sonar`
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>combined-scala-java-multi-module-sonar</artifactId>
<groupId>test</groupId>
<version>1.0.0</version>
</parent>
<artifactId>module1</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package module1;

/**
* Created by tim on 01/05/15.
*/
public class HelloWorld {

public String hello() {
return "Hello";
}

public void notCovered() {
System.out.println("YOLO");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package module1

class HelloScala {

case class TryOut(some: String, fields: List[String])

def test = "Hello"

def someOther = 42
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package module1;

import static org.junit.Assert.assertEquals;

public class HelloWorldTest {

@org.junit.Test
public void testHello() throws Exception {
assertEquals("Hello", new HelloWorld().hello());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FlatSpec, ShouldMatchers}
import module1.HelloScala

@RunWith(classOf[JUnitRunner])
class HelloScalaTest extends FlatSpec with ShouldMatchers {

"it" should "work" in {
val scala: HelloScala = new HelloScala()
scala.test should equal("Hello")

scala.TryOut("String", List()) should not equal(true)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>combined-scala-java-multi-module-sonar</artifactId>
<groupId>test</groupId>
<version>1.0.0</version>
</parent>
<artifactId>module2</artifactId>
<packaging>jar</packaging>
<version>1.0.0</version>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package module2;

/**
* Created by tim on 01/05/15.
*/
public class HelloWorld2 {

public String hello() {
return "Hello";
}

public void notCovered() {
System.out.println("YOLO");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package module2

class HelloScala2 {

case class TryOut(some: String, fields: List[String])

def test = "Hello"

def someOther = 42
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import module2.HelloWorld2;

import static org.junit.Assert.assertEquals;

public class HelloWorld2Test {

@org.junit.Test
public void testHello() throws Exception {
assertEquals("Hello", new HelloWorld2().hello());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import module2.HelloScala2
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FlatSpec, ShouldMatchers}

@RunWith(classOf[JUnitRunner])
class HelloScala2Test extends FlatSpec with ShouldMatchers {

"it" should "work" in {
val scala: HelloScala2 = new HelloScala2()
scala.test should equal("Hello")

scala.TryOut("String", List()) should not equal(true)
}

}
Loading

0 comments on commit 5ece71d

Please sign in to comment.