Class CodeNarc

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
All Implemented Interfaces:
Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, Named, ExtensionAware, Reporting<CodeNarcReports>, Task, PatternFilterable, VerificationTask, Configurable<Task>

@CacheableTask public abstract class CodeNarc extends AbstractCodeQualityTask implements Reporting<CodeNarcReports>
Runs CodeNarc against some source files.
  • Constructor Details

    • CodeNarc

      public CodeNarc()
  • Method Details

    • getConfigFile

      @Internal public File getConfigFile()
      The CodeNarc configuration file to use.
    • getSource

      @PathSensitive(RELATIVE) public FileTree getSource()
      Returns the source for this task, after the include and exclude patterns have been applied. Ignores source files which do not exist.

      The PathSensitivity for the sources is configured to be PathSensitivity.ABSOLUTE. If your sources are less strict, please change it accordingly by overriding this method in your subclass.

      Overrides:
      getSource in class SourceTask
      Returns:
      The source.
    • setConfigFile

      public void setConfigFile(File configFile)
      The CodeNarc configuration file to use.
    • run

      public void run()
    • reports

      public CodeNarcReports reports(Closure closure)
      Configures the reports to be generated by this task.
      Specified by:
      reports in interface Reporting<CodeNarcReports>
      Parameters:
      closure - The configuration
      Returns:
      The report container
    • reports

      public CodeNarcReports reports(Action<? super CodeNarcReports> configureAction)
      Configures the reports to be generated by this task.
      Specified by:
      reports in interface Reporting<CodeNarcReports>
      Parameters:
      configureAction - The configuration
      Returns:
      The report container
    • getCodenarcClasspath

      @Classpath public FileCollection getCodenarcClasspath()
      The class path containing the CodeNarc library to be used.
    • setCodenarcClasspath

      public void setCodenarcClasspath(FileCollection codenarcClasspath)
      The class path containing the CodeNarc library to be used.
    • getCompilationClasspath

      @Classpath public FileCollection getCompilationClasspath()
      The class path to be used by CodeNarc when compiling classes during analysis.
      Since:
      4.2
    • setCompilationClasspath

      public void setCompilationClasspath(FileCollection compilationClasspath)
      The class path to be used by CodeNarc when compiling classes during analysis.
      Since:
      4.2
    • getConfig

      public TextResource getConfig()
      The CodeNarc configuration to use. Replaces the configFile property.
      Since:
      2.2
    • setConfig

      public void setConfig(TextResource config)
      The CodeNarc configuration to use. Replaces the configFile property.
      Since:
      2.2
    • getMaxPriority1Violations

      @Input public int getMaxPriority1Violations()
      The maximum number of priority 1 violations allowed before failing the build.
    • setMaxPriority1Violations

      public void setMaxPriority1Violations(int maxPriority1Violations)
      The maximum number of priority 1 violations allowed before failing the build.
    • getMaxPriority2Violations

      @Input public int getMaxPriority2Violations()
      The maximum number of priority 2 violations allowed before failing the build.
    • setMaxPriority2Violations

      public void setMaxPriority2Violations(int maxPriority2Violations)
      The maximum number of priority 2 violations allowed before failing the build.
    • getMaxPriority3Violations

      @Input public int getMaxPriority3Violations()
      The maximum number of priority 3 violations allowed before failing the build.
    • setMaxPriority3Violations

      public void setMaxPriority3Violations(int maxPriority3Violations)
      The maximum number of priority 3 violations allowed before failing the build.
    • getReports

      public CodeNarcReports getReports()
      The reports to be generated by this task.
      Specified by:
      getReports in interface Reporting<CodeNarcReports>
      Returns:
      The report container