org.gradle.api.plugins.quality

## 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.CodeNarc

- All Implemented Interfaces:
    Comparable<Task>, org.gradle.api.internal.DynamicObjectAware, org.gradle.api.internal.IConventionAware, org.gradle.api.internal.TaskInternal, ExtensionAware, Reporting<CodeNarcReports>, Task, PatternFilterable, VerificationTask, org.gradle.util.Configurable<Task>

      @CacheableTask
      public class CodeNarc
      extends SourceTask
      implements VerificationTask, Reporting<CodeNarcReports>

  Runs CodeNarc against some source files.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface org.gradle.api.Task

      `Task.Namer`

  - ### Field Summary

    - ### Fields inherited from class org.gradle.api.tasks.SourceTask

      `source`

    - ### Fields inherited from interface org.gradle.api.Task

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

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CodeNarc()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `org.gradle.api.internal.project.IsolatedAntBuilder` | `getAntBuilder()`
    `FileCollection` | `getCodenarcClasspath()` The class path containing the CodeNarc library to be used.
    `TextResource` | `getConfig()` The CodeNarc configuration to use.
    `File` | `getConfigFile()` The CodeNarc configuration file to use.
    `boolean` | `getIgnoreFailures()` Whether or not the build should break when the verifications performed by this task fail.
    `org.gradle.internal.reflect.Instantiator` | `getInstantiator()`
    `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(Action<? super CodeNarcReports> configureAction)` Configures the reports to be generated by this task.
    `CodeNarcReports` | `reports(Closure closure)` Configures the reports to be generated by this task.
    `void` | `run()`
    `void` | `setCodenarcClasspath(FileCollection codenarcClasspath)`
    `void` | `setConfig(TextResource config)`
    `void` | `setConfigFile(File configFile)` The CodeNarc configuration file to use.
    `void` | `setIgnoreFailures(boolean ignoreFailures)` Specifies whether the build should break when the verifications performed by this task fail.
    `void` | `setMaxPriority1Violations(int maxPriority1Violations)`
    `void` | `setMaxPriority2Violations(int maxPriority2Violations)`
    `void` | `setMaxPriority3Violations(int maxPriority3Violations)`

    - ### Methods inherited from class org.gradle.api.tasks.SourceTask

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

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

      `conventionMapping, conventionMapping, getConventionMapping`

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

      `addValidator, appendParallelSafeAction, compareTo, configure, deleteAllActions, dependsOn, dependsOnTaskDidWork, doFirst, doFirst, doLast, doLast, execute, finalizedBy, getActionClassLoaders, getActions, getAnt, getAsDynamicObject, getConvention, getDependsOn, getDescription, getDidWork, getEnabled, getExecuter, getExtensions, getFinalizedBy, getGroup, getIdentityPath, getImpliesSubProjects, getInputs, getLogger, getLogging, getMustRunAfter, getName, getOnlyIf, getOutputs, getPath, getProject, getServices, getShouldRunAfter, getStandardOutputCapture, getState, getTaskActions, getTaskDependencies, getTemporaryDir, getTemporaryDirFactory, getValidators, hasProperty, injectIntoNewInstance, isEnabled, isHasCustomActions, leftShift, mustRunAfter, onlyIf, onlyIf, prependParallelSafeAction, property, setActions, setDependsOn, setDescription, setDidWork, setEnabled, setExecuter, setFinalizedBy, setGroup, setImpliesSubProjects, setMustRunAfter, setOnlyIf, setOnlyIf, setProperty, setShouldRunAfter, shouldRunAfter, toString`

    - ### Methods inherited from class java.lang.Object

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

- - ### Constructor Detail

    - #### CodeNarc

          public CodeNarc()

  - ### Method Detail

    - #### getConfigFile

          @Internal
          public File getConfigFile()

      The CodeNarc configuration file to use.

    - #### getSource

          @PathSensitive(value=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.
      Overrides:
        `getSource` in class `SourceTask`
      Returns:
        The source.

    - #### setConfigFile

          public void setConfigFile(File configFile)

      The CodeNarc configuration file to use.

    - #### getInstantiator

          @Inject
          public org.gradle.internal.reflect.Instantiator getInstantiator()

    - #### getAntBuilder

          @Inject
          public org.gradle.api.internal.project.IsolatedAntBuilder getAntBuilder()

    - #### 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)

    - #### getConfig

          @Incubating
          public TextResource getConfig()

      The CodeNarc configuration to use. Replaces the `configFile` property.
      Since:
        2.2

    - #### setConfig

          public void setConfig(TextResource config)

    - #### getMaxPriority1Violations

          @Input
          public int getMaxPriority1Violations()

      The maximum number of priority 1 violations allowed before failing the build.

    - #### setMaxPriority1Violations

          public void setMaxPriority1Violations(int maxPriority1Violations)

    - #### getMaxPriority2Violations

          @Input
          public int getMaxPriority2Violations()

      The maximum number of priority 2 violations allowed before failing the build.

    - #### setMaxPriority2Violations

          public void setMaxPriority2Violations(int maxPriority2Violations)

    - #### getMaxPriority3Violations

          @Input
          public int getMaxPriority3Violations()

      The maximum number of priority 3 violations allowed before failing the build.

    - #### setMaxPriority3Violations

          public void setMaxPriority3Violations(int maxPriority3Violations)

    - #### getReports

          public CodeNarcReports getReports()

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

    - #### getIgnoreFailures

          @Input
          public boolean getIgnoreFailures()

      Whether or not the build should break when the verifications performed by this task fail.
      Specified by:
        `getIgnoreFailures` in interface `VerificationTask`
      Returns:
        false, when the build should break on failure, true when the failures should be ignored.

    - #### setIgnoreFailures

          public void setIgnoreFailures(boolean ignoreFailures)

      Description copied from interface: `VerificationTask`
      Specifies whether the build should break when the verifications performed by this task fail.
      Specified by:
        `setIgnoreFailures` in interface `VerificationTask`
      Parameters:
        `ignoreFailures` - false to break the build on failure, true to ignore the failures. The default is false.