Package: groovy.org.codenarc.report

## [Groovy] Class HtmlReportWriter

- groovy.org.codenarc.report.HtmlReportWriter

- ReportWriter that generates an HTML report.

  The default localized messages, including rule descriptions, are read from the "codenarc-base-messages" ResourceBundle. You can override these messages using the normal ResourceBundle mechanisms (i.e. creating a locale-specific resource bundle file on the classpath, such as "codenarc-base-messages_de"). You can optionally add rule descriptions for custom rules by placing them within a "codenarc-messages.properties" file on the classpath, with entries of the form: {rule-name}.description=..."

  Set the includeSummaryByPackage property to false to exclude the violation summary for each package within the "Summary" section of the report. It defaults to true.

  Set the maxPriority property to control the maximum priority level for violations in the report. For instance, setting maxPriority to 2 will result in the report containing only priority 1 and 2 violations (and omitting violations with priority 3). The maxPriority property defaults to 3.
  Authors:
    Chris Mair

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static def` | `DEFAULT_OUTPUT_FILE` |

  - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class AbstractReportWriter` | `BASE_MESSAGES_BUNDLE, CODENARC_URL, CUSTOM_MESSAGES_BUNDLE, VERSION_FILE, customMessagesBundleName, getTimestamp, initializeResourceBundle, resourceBundle`

  - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `String` | `defaultOutputFile`
    `boolean` | `includeSummaryByPackage`
    `int` | `maxPriority`
    `String` | `title`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `protected String` | `formatSourceLine(String sourceLine, int startColumn = 0)` Format and trim the source line.
    `` | `protected boolean` | `isDirectoryContainingFiles(Results results)` Return true if the Results represents a directory that contains at least one file
    `` | `protected boolean` | `isDirectoryContainingFilesWithViolations(Results results)` Return true if the Results represents a directory that contains at least one file with one or more violations.
    `` | `String` | `toString()`
    `` | `void` | `writeReport(Writer writer, AnalysisContext analysisContext, Results results)` Write out a report to the specified Writer for the analysis results

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class AbstractReportWriter` | `getCodeNarcVersion, getDescriptionForRule, getFormattedTimestamp, getHtmlDescriptionForRule, getResourceBundleString, getSortedRules, initializeDefaultResourceBundle, isEnabled, writeReport, writeReport`

- - ### Field Detail

    - #### public static final def DEFAULT_OUTPUT_FILE

  - ### Property Detail

    - #### String defaultOutputFile

    - #### boolean includeSummaryByPackage

    - #### int maxPriority

    - #### String title

  - ### Method Detail

    - #### protected String formatSourceLine(String sourceLine, int startColumn = 0)

      Format and trim the source line. If the whole line fits, then include the whole line (trimmed). Otherwise, remove characters from the middle to truncate to the max length.

      Parameters:
        `sourceLine` - - the source line to format
        `startColumn` - - the starting column index; used to truncate the line if it's too long; defaults to 0
      Returns:
        the formatted and trimmed source line

    - #### protected boolean isDirectoryContainingFiles(Results results)

      Return true if the Results represents a directory that contains at least one file

      Parameters:
        `results` - - the Results

    - #### protected boolean isDirectoryContainingFilesWithViolations(Results results)

      Return true if the Results represents a directory that contains at least one file with one or more violations.

      Parameters:
        `results` - - the Results

    - #### String toString()

    - #### void writeReport(Writer writer, AnalysisContext analysisContext, Results results)

      Write out a report to the specified Writer for the analysis results

      Parameters:
        `analysisContext` - - the AnalysisContext containing the analysis configuration information
        `results` - - the analysis results