# Class CodeNarc

java.lang.Object
org.gradle.api.internal.AbstractTask
org.gradle.api.DefaultTask
org.gradle.api.internal.ConventionTask
org.gradle.api.tasks.SourceTask
org.gradle.api.plugins.quality.AbstractCodeQualityTask
org.gradle.api.plugins.quality.CodeNarc

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.

Since:
  0.8

- ## Nested Class Summary

  ### Nested classes/interfaces inherited from interface Named

  `Named.Namer`

- ## Field Summary

  ### Fields inherited from interface Task

  `TASK_ACTION, TASK_CONSTRUCTOR_ARGS, TASK_DEPENDS_ON, TASK_DESCRIPTION, TASK_GROUP, TASK_NAME, TASK_OVERWRITE, TASK_TYPE`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CodeNarc()`
  Creates a new `CodeNarc`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `FileCollection`
  `getCodenarcClasspath()`
  The class path containing the CodeNarc library to be used.
  `FileCollection`
  `getCompilationClasspath()`
  The class path to be used by CodeNarc when compiling classes during analysis.
  `TextResource`
  `getConfig()`
  The CodeNarc configuration to use.
  `File`
  `getConfigFile()`
  The CodeNarc configuration file to use.
  `int`
  `getMaxPriority1Violations()`
  The maximum number of priority 1 violations allowed before failing the build.
  `int`
  `getMaxPriority2Violations()`
  The maximum number of priority 2 violations allowed before failing the build.
  `int`
  `getMaxPriority3Violations()`
  The maximum number of priority 3 violations allowed before failing the build.
  `CodeNarcReports`
  `getReports()`
  The reports to be generated by this task.
  `FileTree`
  `getSource()`
  Returns the source for this task, after the include and exclude patterns have been applied.
  `CodeNarcReports`
  `reports(Closure closure)`
  Configures the reports to be generated by this task.
  `CodeNarcReports`
  `reports(Action<? super CodeNarcReports> configureAction)`
  Configures the reports to be generated by this task.
  `void`
  `run()`
  Run.
  `void`
  `setCodenarcClasspath(FileCollection codenarcClasspath)`
  The class path containing the CodeNarc library to be used.
  `void`
  `setCompilationClasspath(FileCollection compilationClasspath)`
  The class path to be used by CodeNarc when compiling classes during analysis.
  `void`
  `setConfig(TextResource config)`
  The CodeNarc configuration to use.
  `void`
  `setConfigFile(File configFile)`
  The CodeNarc configuration file to use.
  `void`
  `setMaxPriority1Violations(int maxPriority1Violations)`
  The maximum number of priority 1 violations allowed before failing the build.
  `void`
  `setMaxPriority2Violations(int maxPriority2Violations)`
  The maximum number of priority 2 violations allowed before failing the build.
  `void`
  `setMaxPriority3Violations(int maxPriority3Violations)`
  The maximum number of priority 3 violations allowed before failing the build.

  ### Methods inherited from class AbstractCodeQualityTask

  `configureForkOptions, getIgnoreFailures, getIgnoreFailuresProperty, getJavaLauncher, getMaxHeapSize, getMinHeapSize, getObjectFactory, getToolchainService, getWorkerExecutor, setIgnoreFailures`

  ### Methods inherited from class SourceTask

  `exclude, exclude, exclude, exclude, getExcludes, getIncludes, getPatternSet, getPatternSetFactory, include, include, include, include, setExcludes, setIncludes, setSource, setSource, source`

  ### Methods inherited from class org.gradle.api.internal.ConventionTask

  `conventionMapping, conventionMapping, getConventionMapping`

  ### Methods inherited from class DefaultTask

  `compareTo, configure, dependsOn, doFirst, doFirst, doFirst, doLast, doLast, doLast, finalizedBy, getActions, getAnt, getDependsOn, getDescription, getDestroyables, getDidWork, getEnabled, getExtensions, getFinalizedBy, getGroup, getInputs, getLocalState, getLogger, getLogging, getMustRunAfter, getName, getOutputs, getPath, getProject, getShouldRunAfter, getState, getTaskDependencies, getTemporaryDir, getTimeout, hasProperty, mustRunAfter, onlyIf, onlyIf, onlyIf, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setFinalizedBy, setGroup, setMustRunAfter, setOnlyIf, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, usesService`

  ### Methods inherited from class org.gradle.api.internal.AbstractTask

  `acceptServiceReferences, appendParallelSafeAction, doNotTrackState, doNotTrackStateIf, getAsDynamicObject, getIdentityPath, getImpliesSubProjects, getLifecycleDependencies, getLoggingManager, getOnlyIf, getReasonNotToTrackState, getReasonsNotToTrackState, getReasonTaskIsIncompatibleWithConfigurationCache, getRequiredServices, getServices, getSharedResources, getStandardOutputCapture, getTaskActions, getTaskIdentity, getTemporaryDirFactory, hasTaskActions, injectIntoNewInstance, isCompatibleWithConfigurationCache, isEnabled, isHasCustomActions, notCompatibleWithConfigurationCache, prependParallelSafeAction, restoreOnlyIf, restoreTaskActions, service, setImpliesSubProjects`

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface Task

  `doNotTrackState, notCompatibleWithConfigurationCache, service`

- ## Constructor Details

  - ### CodeNarc

    public CodeNarc()
    Creates a new `CodeNarc`.
    Since:
      0.8

- ## Method Details

  - ### getConfigFile

    @Internal public File getConfigFile()
    The CodeNarc configuration file to use.
    Since:
      0.8

  - ### 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.
    Since:
      0.8

  - ### run

    public void run()
    Run.
    Since:
      1.0

  - ### 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.
    Since:
      1.0

  - ### setCodenarcClasspath

    public void setCodenarcClasspath(FileCollection codenarcClasspath)
    The class path containing the CodeNarc library to be used.
    Since:
      1.0

  - ### 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.
    Since:
      1.7

  - ### setMaxPriority1Violations

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

  - ### getMaxPriority2Violations

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

  - ### setMaxPriority2Violations

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

  - ### getMaxPriority3Violations

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

  - ### setMaxPriority3Violations

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

  - ### getReports

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