I cannot seem to trigger the code duplication check of sonar.
Here is the output saying no code duplications:
https://sonarcloud.io/dashboard?id=org.rulez.demokracia%3APDEngine&pullRequest=273
Here is the build output: https://app.shippable.com/github/edemo/PDEngine/runs/548/summary/console
Here is the pull request with all the code: https://github.com/edemo/PDEngine/pull/273
I am using sonar-maven-plugin:3.6.0.1398:sonar
The code executing it:
mvn sonar:sonar -Dsonar.organization=edemo
-Dsonar.pullrequest.provider=github
-Dsonar.pullrequest.github.repository={REPO_FULL_NAME} \
-Dsonar.pullrequest.branch={HEAD_BRANCH}
-Dsonar.pullrequest.key={PULL_REQUEST}\
-Dsonar.pullrequest.base={BASE_BRANCH}
-Dsonar.github.oauth={GITHUB_OAUTH}\
-Dsonar.github.repository={REPO_FULL_NAME}
-Dsonar.issuesReport.console.enable=true
-Dsonar.github.login=magwas
-Dsonar.externalIssuesReportPaths=issuesReport.json
-Dsonar.cpd.{language}.minimumTokens=2\
-Dsonar.cpd.{language}.minimumLines=2
The project contains this code:
@tested_feature("Vote")
@tested_operation("Cast vote")
@tested_behaviour("if there was a cast vote from the same user, the old one is deleted")
@Test
public void cast_vote_records_the_vote_with_different_user_votesCast() {
String ballot = voteManager.obtainBallot(adminInfo.voteId, adminInfo.adminKey);
List<RankedChoice> theCastVote = new ArrayList<RankedChoice>();
Vote vote = getTheVote();
vote.canVote = true;
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
voteManager.castVote(adminInfo.voteId, ballot, theCastVote);
CastVote voteCast = new CastVote("test_user_in_ws_context", theCastVote, "Secret");
assertTrue(voteCast.preferences.containsAll(vote.votesCast.get(0).preferences));
}
@tested_feature("Vote")
@tested_operation("Cast vote")
@tested_behaviour("if there was a cast vote from the same user, the old one is deleted")
@Test
public void this_is_the_same_test_as_above() {
String ballot = voteManager.obtainBallot(adminInfo.voteId, adminInfo.adminKey);
List<RankedChoice> theCastVote = new ArrayList<RankedChoice>();
Vote vote = getTheVote();
vote.canVote = true;
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
vote.votesCast.clear();
vote.addCastVote("OtherUser", theCastVote, "OtherSecret");
voteManager.castVote(adminInfo.voteId, ballot, theCastVote);
CastVote voteCast = new CastVote("test_user_in_ws_context", theCastVote, "Secret");
assertTrue(voteCast.preferences.containsAll(vote.votesCast.get(0).preferences));
}