Skip to content

Commit

Permalink
[MPMD-322] Display when PMD/CPD is skipped
Browse files Browse the repository at this point in the history
  • Loading branch information
adangel committed Sep 2, 2021
1 parent b8fc018 commit 45a5e54
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/main/java/org/apache/maven/plugins/pmd/CpdReport.java
Expand Up @@ -170,6 +170,7 @@ public boolean canGenerateReport()
{
if ( skip )
{
getLog().info( "Skipping CPD execution" );
return false;
}

Expand Down
Expand Up @@ -75,10 +75,13 @@ public CpdViolationCheckMojo()
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( !skip )
if ( skip )
{
executeCheck( "cpd.xml", "duplication", "CPD duplication", 10 );
getLog().info( "Skipping CPD execution" );
return;
}

executeCheck( "cpd.xml", "duplication", "CPD duplication", 10 );
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/apache/maven/plugins/pmd/PmdReport.java
Expand Up @@ -315,6 +315,7 @@ public boolean canGenerateReport()
{
if ( skip )
{
getLog().info( "Skipping PMD execution" );
return false;
}

Expand Down
Expand Up @@ -84,10 +84,13 @@ public PmdViolationCheckMojo()
public void execute()
throws MojoExecutionException, MojoFailureException
{
if ( !skip )
if ( skip )
{
executeCheck( "pmd.xml", "violation", "PMD violation", failurePriority );
getLog().info( "Skipping PMD execution" );
return;
}

executeCheck( "pmd.xml", "violation", "PMD violation", failurePriority );
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/org/apache/maven/plugins/pmd/PmdReportTest.java
Expand Up @@ -365,6 +365,10 @@ public void testSkipConfiguration()

generatedFile = new File( getBasedir(), "target/test/unit/custom-configuration/target/site/pmd.html" );
assertFalse( FileUtils.fileExists( generatedFile.getAbsolutePath() ) );

// the fact, the PMD execution has been skipped, should be logged
String output = CapturingPrintStream.getOutput();
assertTrue ( output.contains( "Skipping PMD execution" ) );
}

public void testSkipEmptyReportConfiguration()
Expand Down

0 comments on commit 45a5e54

Please sign in to comment.