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

updated jacoco to 0.8.2 for java 10+ support #84

Open
wants to merge 91 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
91 commits
Select commit Hold shift + click to select a range
42f2057
Adjust version to 1.6-SNAPSHOT
TobiX Nov 14, 2018
e488f54
Drop SonarSource organization (#65)
ganncamp Feb 12, 2018
913055a
Update to SonarQube 6.7 (LTS)
TobiX Jan 15, 2019
c952e1c
Update JaCoCo to 0.8.2 for Java 10+ support
TobiX Jan 15, 2019
df5200d
Add SonarCloud integration
TobiX Jan 15, 2019
bac64f5
Add myself to developers
TobiX Jan 15, 2019
c6385d7
Minor dependency updates
TobiX Jan 15, 2019
f9bee4d
Update parent and license headers
TobiX Jan 15, 2019
bf434e8
Record coverage with JaCoCo
TobiX Jan 15, 2019
2217e89
[travis] Clone complete history for SonarCloud
TobiX Jan 15, 2019
51c5a4b
Update badges and version overview
TobiX Jan 15, 2019
9ed789b
Clarify preferred code style & add fmt-maven-plugin
TobiX Jan 16, 2019
31d93c0
remove misleading log entry (#76)
CCFenner Sep 3, 2018
8d86dea
remove duplicate log entry (#75)
CCFenner Sep 3, 2018
7b309a8
align config property name (#69)
CCFenner Apr 25, 2018
289173f
Remove deprecated GroovyFileSystem.sourceFiles
TobiX Jan 17, 2019
ad49501
Stream files from SonarQube to CodeNarc
TobiX Jan 17, 2019
0935f2d
Add AppVeyor configuration
TobiX Jan 26, 2019
d6c5a19
Add AppVeyor badge to README
TobiX Jan 26, 2019
b923c29
Update project location in Maven pom.xml
TobiX Mar 13, 2019
2e142e5
Integrate codenarc converter into the default build
TobiX Mar 13, 2019
c2e1b79
Fix travis builds on external branches
TobiX Mar 13, 2019
351c1a7
Remove usage of MutableTestCase & MutableTestPlan
TobiX Mar 13, 2019
4d49345
Use 'Paths.get(".")' for current directory in tests
TobiX Mar 19, 2019
a9e5e8c
Some simple fixes for deprecation warnings
TobiX Mar 19, 2019
c80bc44
Replace mocks with temporary directories
TobiX Mar 19, 2019
83b6194
Replace deprecated RulesProfile for scanner-side operations (#4)
Hydragyrum Feb 22, 2019
d9eb453
Replace mocked ActiveRules with real classes
TobiX Mar 19, 2019
757d046
Create a wrapper around ActiveRulesBuilder
TobiX Mar 19, 2019
b355e42
Include CodeNarc as a git submodule
TobiX Mar 24, 2019
80214cc
Add SonarQube 7.7 to Travis-CI test matrix
TobiX Mar 24, 2019
9b75cbe
Remove coupling metrics
TobiX Mar 25, 2019
644cba9
Fix project description
TobiX Mar 25, 2019
13cd60f
update data used in marketplace (#7)
CCFenner Mar 26, 2019
fd86fbd
"Ignore" source directories in cobertura reports
TobiX Mar 26, 2019
d5c685c
Only report overall JaCoCo coverage
TobiX Mar 26, 2019
808e051
Travis-CI: Tests now run on all configurations
TobiX Mar 26, 2019
dc75de6
SONAR-11064: Drop unused metric "comment_lines_data"
TobiX Mar 28, 2019
8896518
Repair GMetrics metrics test
TobiX Mar 28, 2019
f0d9d84
Remove old metrics (fixes #6)
TobiX Mar 28, 2019
cbffdcf
Enable JaCoCo coverage on all modules
TobiX Mar 28, 2019
76b55b8
Only run SonarQube analysis on one Travis-CI matrix configuration
TobiX Mar 28, 2019
57bbb78
Travis-CI: Install step is redundant
TobiX Mar 28, 2019
2bac5bb
Clean up logging in codenarc converter
TobiX Mar 28, 2019
7dc439d
Fix Travis-CI URL
TobiX Mar 28, 2019
e3ce9b4
Make RuleParameter immutable (using AutoValue)
TobiX Apr 8, 2019
b8bea33
Run the CodeNarc converter on each build
TobiX Apr 20, 2019
4dc1bf0
Update submodules in AppVeyor
TobiX Apr 20, 2019
32a622c
Make sure the submodule really was checked out
TobiX Apr 20, 2019
fdd2aea
Fix minor issues (XXE in local tool)
TobiX Apr 20, 2019
4f1fcf2
Completly exclude groovy-ant
TobiX May 12, 2019
959caee
Fix typo
TobiX May 12, 2019
a4b08f9
Get rid of RemediationEffortExtractor
TobiX May 13, 2019
9a8fd4d
Remove obsolete dependencyManagement for groovy-ant
TobiX May 13, 2019
0deeece
Sort RuleSet enum
TobiX May 13, 2019
00e5e28
Sort rules.xml the same way as the RuleSet enum
TobiX May 13, 2019
a62fab1
Add "support" for SonarQube 7.8
TobiX Jun 24, 2019
9ab4aa9
Add SonarSource bintray repository
TobiX Jun 24, 2019
2aab148
Improve rule descriptions
TobiX Jun 28, 2019
6527236
Simpler (and correcter) paragraph parsing
TobiX Jun 28, 2019
3d3a8f1
Update CodeNarc to 0.26.0
TobiX Apr 20, 2019
bf482ff
Update CodeNarc to 0.27.0
TobiX Apr 20, 2019
9fc3977
Update CodeNarc and GMetrics to 1.0
TobiX May 13, 2019
e6bbce3
Update CodeNarc to 1.1
TobiX May 13, 2019
50a5a0f
Update CodeNarc to 1.2
TobiX Jun 26, 2019
fbdc546
Update CodeNarc to 1.3
TobiX Jun 27, 2019
6f09fdd
Update CodeNarc to 1.4
TobiX Jun 27, 2019
075f1a3
Merge pull request #13 from Inform-Software/new-codenarc
TobiX Jun 29, 2019
a27f664
Minor README updates
TobiX Jun 29, 2019
1ace6cc
Add changelog
TobiX Jun 29, 2019
6f5204d
Fix diff ranges in changelog
TobiX Jun 29, 2019
6d2e724
Update parent and dependencies
TobiX Jun 30, 2019
8b4057a
Add support for SonarQube 7.9
TobiX Jul 2, 2019
3e38646
Travis: Test against Java 8 & 11
TobiX Jul 4, 2019
028c327
Configure maven-release-plugin
TobiX Jul 4, 2019
612d9fd
[maven-release-plugin] prepare release 1.6
TobiX Jul 4, 2019
3e02657
[maven-release-plugin] prepare for next development iteration
TobiX Jul 4, 2019
3219bb6
Update README and CHANGELOG
TobiX Jul 4, 2019
0999d2b
Remove backward compatibility hacks
TobiX Dec 10, 2019
a8b75bc
Minor dependency updates
TobiX Dec 10, 2019
d536102
Drop compatibility with JaCoCo < 0.7.5
TobiX Dec 10, 2019
cb0dd9b
Travis: Test against SonarQube 8.0
TobiX Dec 15, 2019
6644a0f
Tell Maven to not alter paths for sub-projects
TobiX Dec 15, 2019
df9762e
AppVeyor: Update build image for recent Maven
TobiX Dec 15, 2019
4c1b566
Test against SonarQube 8.3
TobiX May 11, 2020
29fb93d
Disable JaCoCo sensor if JaCoCo XML exists
TobiX May 11, 2020
f043bdf
Remove 'test_success_density' metric (fixes #25)
TobiX May 11, 2020
03fb03e
Update documentation for coverage
TobiX May 12, 2020
2715416
Add distributionManagement for BinTray (see #18)
TobiX May 12, 2020
db7308f
JaCoCoAnalyzer: log missing file only if extension is groovy
pascalporta444 Sep 4, 2020
fc16bfa
Merge branch 'cit'
pascalporta444 Sep 4, 2020
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
17 changes: 17 additions & 0 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '{build}'
image: Visual Studio 2019

cache:
- C:\Users\appveyor\.m2

install:
- git submodule update --init --recursive

build_script:
- mvn verify -B -V -e

artifacts:
- path: 'sonar-groovy-plugin\target\*.jar'

on_failure:
- ps: Get-ChildItem *\target\surefire-reports\*.txt | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name }
23 changes: 23 additions & 0 deletions .github/travis-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

add=

if [ "$SONAR_VERSION" ]
then
add="$add -Dsonar.version=$SONAR_VERSION"

case $SONAR_VERSION in
8*) add="$add -PtestModernSonarQube" ;;
esac

# Workaround until https://jira.sonarsource.com/browse/TRAVIS-19 is fixed
# See also https://community.sonarsource.com/t/travis-plugin-is-failing-on-external-pull-request/807/7
elif [ -n "$SONAR_SCANNER_HOME" ]
then
# Only run SonarQube analysis on one Travis-CI matrix configuration
# (namely: empty $SONAR_VERSION and Java 8
java -Xmx32m -version 2>&1 | grep -q 1.8.0 && add="sonar:sonar $add"
fi

mvn -B -V -e -Dstyle.color=always verify $add

3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "codenarc-converter/CodeNarc"]
path = codenarc-converter/CodeNarc
url = ../../CodeNarc/CodeNarc.git
1 change: 1 addition & 0 deletions .mvn/maven.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-Pcoverage
32 changes: 23 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
language: java
sudo: false

jdk:
- oraclejdk8
addons:
apt:
packages:
- oracle-java8-installer
- openjdk8
- openjdk11
env:
- SONAR_VERSION=
- SONAR_VERSION=7.9
- SONAR_VERSION=8.0
- SONAR_VERSION=8.3.0.34182

# Install step is redundant
install: true
script: mvn verify -B -e -V

matrix:
fast_finish: true
script:
- .github/travis-build.sh

dist: xenial

cache:
directories:
- '$HOME/.m2/repository'
- '$HOME/.sonar/cache'

addons:
sonarcloud:
organization: "tobix-github"
token:
secure: "pYxJ0DaMAkDCTjuRrfvSbkMy4tM82JHMoFagVIIaqVY6fIaltfi9QB4U6p9a8OzXLs601Cr4btwWAPpqi5GfMaDbdOzCBxz2mfoO8skawCTr0M2Ij8yaStgiNoIornqCT1VyKRE4mOJMeX2ayqyiKvn0gCFliV8dwg+4zl1vv1bdCsUzSGLPKFRv2KWFRnPbBjeimwCySImdAzn5IMOA3r583kAkuTQqJNH2ai60QEAZpWRN9E98ZkwYwsf/+7i/1NbURL/a+km3Eq+E10unblx66zpARA5k10Ygg9xP8c4+PtvVOTW3zlQbLsvp+d1Bz+kkkvBjbX6rxhxtlQ5uMbw2H9zyXVgwUtZz/4Dq4J3pbWx//OA6K+NVKwVmEuogR2Kdxbbbehp3v1MjNx7YP+82sMx+6vSHR5aH/wmBe2VEtSXZeOmKPkpGNXlRduMOsgyP+yU3xqCUX9EFCMcepEcoM9wPWfTMxLUyfrD1MP1yzC5gTMRVBNoE5pO+WopE2JFUOYmtRz5hpU6DYLHjQ5dSDRl2g7Ig7/3FrDzaVrAd8XIDvIz34UGwTarpEDIQrIM2EmHglOXclRKtll0n4HhcU5eLVhLd7poJpBbtePNnxF+NcaYOk9Qww/i6SigYoA+jKZrNK9N2aQMBXROculcenLenoBUgQwG9yuPeeFw="

# SonarCloud needs unlimited depth
git:
depth: false

notifications:
email: false
77 changes: 77 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [Unreleased]

### Changed
- Remove backwards compatibility hacks (drop support for everything older then
SonarQube 7.8)
- Minor dependency updates
- Deprecates support for JaCoCo binary format (use the SonarQube JaCoCo plugin
instead)

### Removed
- Compatibility with JaCoCo older the 0.7.5 (released in mid-2015)

## [1.6] - 2019-07-04

### Added
- This changelog

### Changed
- Moved project from SonarSource to community
- Update plugin to be compatible with SonarQube 6.7-7.8
- Analyze plugin on SonarCloud
- Do CI builds on Travis & AppVeyor
- Integrate codenarc converter into the default build
- Include CodeNarc as a git submodule (so the converter can run on Travis)
- Fix a bunch of deprecated constructs
- Only report overall JaCoCo test coverage
- Updated CodeNarc to 1.4 & GMetrics to 1.0

### Fixed
- fix multiple codenarc files (pmayweg#60)
- Fix bug in JaCoCo package name handling (pmayweg#74)
- Update JaCoCo for Java 10+ support
- Remove old metrics (fixes #6)

### Removed
- Coupling metrics, since SonarQube doesn't support them anymore

## [1.5] - 2017-05-10

Please see the Git history for older changes

## [1.4-RC1] - 2016-08-05

## [1.3.1] - 2015-12-02

## [1.3] - 2015-11-06

## [1.2] - 2015-08-12

## [1.1.1] - 2015-05-28

## [1.1] - 2015-03-17

## [1.0.1] - 2014-03-14

## [1.0] - 2014-02-24

## [0.6] - 2012-08-06

[Unreleased]: https://github.com/Inform-Software/sonar-groovy/compare/1.6...HEAD
[1.6]: https://github.com/Inform-Software/sonar-groovy/compare/1.5...1.6
[1.5]: https://github.com/Inform-Software/sonar-groovy/compare/1.4-RC1...1.5
[1.4-RC1]: https://github.com/Inform-Software/sonar-groovy/compare/1.3.1...1.4-RC1
[1.3.1]: https://github.com/Inform-Software/sonar-groovy/compare/1.3...1.3.1
[1.3]: https://github.com/Inform-Software/sonar-groovy/compare/1.2...1.3
[1.2]: https://github.com/Inform-Software/sonar-groovy/compare/1.1.1...1.2
[1.1.1]: https://github.com/Inform-Software/sonar-groovy/compare/1.1...1.1.1
[1.1]: https://github.com/Inform-Software/sonar-groovy/compare/1.0.1...1.1
[1.0.1]: https://github.com/Inform-Software/sonar-groovy/compare/1.0...1.0.1
[1.0]: https://github.com/Inform-Software/sonar-groovy/compare/0.6...1.0
[0.6]: https://github.com/Inform-Software/sonar-groovy/releases/tag/0.6

114 changes: 86 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
SonarQube plugin for Groovy
==========
# SonarQube plugin for Groovy

### Build status
[![Build status (Travis CI)](https://travis-ci.com/Inform-Software/sonar-groovy.svg?branch=master)](https://travis-ci.com/Inform-Software/sonar-groovy)
[![Build status (AppVeyor)](https://ci.appveyor.com/api/projects/status/si4v2gs7h4qiv27j/branch/master?svg=true)](https://ci.appveyor.com/project/TobiX/sonar-groovy/branch/master)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=org.sonarsource.groovy%3Agroovy&metric=alert_status)](https://sonarcloud.io/dashboard?id=org.sonarsource.groovy%3Agroovy)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=org.sonarsource.groovy%3Agroovy&metric=coverage)](https://sonarcloud.io/dashboard?id=org.sonarsource.groovy%3Agroovy)

[![Build Status](https://api.travis-ci.org/pmayweg/sonar-groovy.png)](https://travis-ci.org/pmayweg/sonar-groovy)
Get test builds from [AppVeyor](https://ci.appveyor.com/project/TobiX/sonar-groovy/build/artifacts).

## Description
The plugin enables analysis of Groovy within SonarQube.

It leverages [CodeNarc](http://codenarc.sourceforge.net/) to raise issues against coding rules, [GMetrics](http://gmetrics.sourceforge.net/) for cyclomatic complexity and [Cobertura](http://cobertura.sourceforge.net/) or [JaCoCo](http://www.eclemma.org/jacoco/) for code coverage.
This plugin enables analysis of Groovy within SonarQube.

Plugin | 0.1 | 0.2 | 0.3 | 0.4 | 0.5 | 0.6 | 1.0 | 1.1 | 1.1.1 | 1.2 | 1.3 | 1.3.1 | 1.4
---------|-----|-----|------|------|--------|------|------|------|-------|------|--------|--------|-------
CodeNarc | 0.9 | 0.9 | 0.13 | 0.15 | 0.16.1 | 0.17 | 0.20 | 0.23 | 0.23 | 0.24 | 0.24.1 | 0.24.1 | 0.25.2
GMetrics | 0.2 | 0.2 | 0.3 | 0.3 | 0.4 | 0.5 | 0.6 | 0.6 | 0.7 | 0.7 | 0.7 | 0.7 | 0.7
It leverages [CodeNarc](http://codenarc.sourceforge.net/) to raise issues
against coding rules and [GMetrics](http://gmetrics.sourceforge.net/) for
cyclomatic complexity.

For code coverage, the SonarQube [JaCoCo](http://www.eclemma.org/jacoco/)
plugin should be used. Additionally, this plugin still supports importing
binary JaCoCo reports (deprecated, will be removed in the future) and
[Cobertura](http://cobertura.sourceforge.net/).

Plugin | 1.4/1.5 | 1.6 | 1.7
----------|---------|---------|-----
CodeNarc | 0.25.2 | 1.4 | 1.4
GMetrics | 0.7 | 1.0 | 1.0
SonarQube | 5.6-6.7 | 6.7-7.9 | 7.8-8.3

## Steps to Analyze a Groovy Project
1. Install SonarQube Server
Expand All @@ -24,32 +35,79 @@ GMetrics | 0.2 | 0.2 | 0.3 | 0.3 | 0.4 | 0.5 | 0.6 | 0.6 | 0.7 | 0.7
1. Follow the link provided at the end of the analysis to browse your project's quality in SonarQube UI

## Notes
*CodeNarc*
It is possible to reuse a previously generated report from CodeNarc by setting the `sonar.groovy.codenarc.reportPaths` property.

*Groovy File Suffixes*
It is possible to define multiple groovy file suffixes to be recognized by setting the `sonar.groovy.file.suffixes` property. Note that by default, only files having `.groovy` as extension will be analyzed.
*CodeNarc*: It is possible to reuse a previously generated report from CodeNarc
by setting the `sonar.groovy.codenarc.reportPaths` property.

*Unit Tests Execution Reports*
Import unit tests execution reports (JUnit XML format) by setting the sonar.junit.reportsPath property. Default location is _target/surefire-reports_.
*Groovy File Suffixes*: It is possible to define multiple groovy file suffixes
to be recognized by setting the `sonar.groovy.file.suffixes` property. Note
that by default, only files having `.groovy` as extension will be analyzed.

*JaCoCo and Binaries*
The groovy plugin requires access to source binaries when analyzing JaCoCo reports. Consequently, property `sonar.groovy.binaries` has to be configured for the analysis (comma-separated paths to binary folders). For Maven and gradle projects, the property is automatically set.
*Unit Tests Execution Reports*: Import unit tests execution reports (JUnit XML
format) by setting the sonar.junit.reportsPath property. Default location is
_target/surefire-reports_.

*JaCoCo and Binaries*: The groovy plugin requires access to source binaries
when analyzing JaCoCo reports. Consequently, property `sonar.groovy.binaries`
has to be configured for the analysis (comma-separated paths to binary
folders). For Maven and gradle projects, the property is automatically set.

## Coverage Results Import
The Groovy Plugin does not generate its own test coverage report, but re-uses the ones generated by Cobertura or JaCoCo.

For coverage, it is recommended to use the generic [SonarQube JaCoCo
plugin](https://community.sonarsource.com/t/coverage-test-data-importing-jacoco-coverage-report-in-xml-format/12151)
instead of relying on this plugin to import coverage into SonarQube.
Nevertheless, we support importing coverage from Cobertura (but this code path
isn't used by the author of the plugin).

### Code Coverage with Cobertura

To display code coverage data:

1. Prior to the SonarQube analysis, execute your unit tests and generate the Cobertura XML report.
1. Import this report while running the SonarQube analysis by setting the `sonar.groovy.cobertura.reportPath` property to the path to the Cobertura XML report. The path may be absolute or relative to the project base directory.
1. Prior to the SonarQube analysis, execute your unit tests and generate the
Cobertura XML report.
1. Import this report while running the SonarQube analysis by setting the
`sonar.groovy.cobertura.reportPath` property to the path to the Cobertura
XML report. The path may be absolute or relative to the project base
directory.

### Code Coverage with JaCoCo
To display code coverage data:
## Contributions

Contributions via GitHub [issues] and pull requests are very welcome. This
project tries to adhere to the [Google Java Style], but we don't want a global
reformat to keep the Git history readable. To help with this, you can use the
[fmt-maven-plugin] to format your changes:

mvn fmt:format -DfilesNamePattern=TestUtils\.java

You can use the `fileNamePattern` option to restrict the formatter to the files
you changed.

[issues]: https://github.com/Inform-Software/sonar-groovy/issues/new
[Google Java Style]: https://google.github.io/styleguide/javaguide.html
[fmt-maven-plugin]: https://github.com/coveo/fmt-maven-plugin

### Updating CodeNarc

In the directory `codenarc-converter` there is a little helper tool to convert
CodeNarc rules to SonarQube rules. To do its job it needs a source copy of
CodeNarc - this is currently achieved by including the used CodeNarc version as
a git subbmodule. If you need to update CodeNarc, you need to update that
submodule too:

```
git submodule init
cd codenarc-converter/CodeNarc
git checkout vX.Y.Z
cd ..
git add CodeNarc
```

You should then run the `codenarc-converter` (Running `mvn verify` should be
enough if the project is set up correctly) and merge descriptions from
`codenarc-converter/target/results/rules.xml` into
`sonar-groovy-plugin/src/main/resources/org/sonar/plugins/groovy/rules.xml`.
The converter does a pretty crude job converting CodeNarc's [APT] documentation
into SonarQube rule descriptions.

1. Prior to the SonarQube analysis, execute your tests and generate the JaCoCo exec file(s).
1. In order to be able to read the exec report file, and as JaCoCo bases its analysis on binaries, set the sonar.binaries property.
1. Set the `sonar.groovy.jacoco.reportPath` property to the path to the JaCoCo exec file related to your unit tests.
1. (Optional) If you are running integration tests on top of your unit tests, you may want to set the `sonar.groovy.jacoco.itReportPath` to the path to JaCoCo exec file related to the integration tests.
1. Run the SonarQube analysis.
[APT]: https://maven.apache.org/doxia/references/apt-format.html
1 change: 1 addition & 0 deletions codenarc-converter/CodeNarc
Submodule CodeNarc added at e32d9b
Loading