Class MultipleStringLiteralsExtendedCheck

  • All Implemented Interfaces:
    com.puppycrawl.tools.checkstyle.api.Configurable, com.puppycrawl.tools.checkstyle.api.Contextualizable

    public class MultipleStringLiteralsExtendedCheck
    extends com.puppycrawl.tools.checkstyle.api.AbstractCheck
    Checks for multiple occurrences of the same string literal within a single file.
    Since:
    1.5.3
    Author:
    Daniel Grenner
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

        com.puppycrawl.tools.checkstyle.api.AutomaticBean.OutputStreamOptions
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String MSG_KEY
      A key is pointing to the warning message text in "messages.properties" file.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void beginTree​(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)  
      void finishTree​(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)  
      int[] getAcceptableTokens()  
      int[] getDefaultTokens()  
      int[] getRequiredTokens()  
      void setAllowedDuplicates​(int allowedDuplicates)
      Sets the maximum allowed duplicates of a string.
      void setHighlightAllDuplicates​(boolean highlightAllDuplicates)
      Sets highlight for all duplicates or only first.
      void setIgnoreOccurrenceContext​(String... strRep)
      Adds a set of tokens the check is interested in.
      void setIgnoreStringsRegexp​(String ignoreStringsRegexp)
      Sets regexp pattern for ignored strings.
      void visitToken​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)  
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractCheck

        clearViolations, destroy, getFileContents, getFilePath, getLine, getLineCodePoints, getLines, getTabWidth, getTokenNames, getViolations, init, isCommentNodesRequired, leaveToken, log, log, log, setFileContents, setTabWidth, setTokens
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AbstractViolationReporter

        finishLocalSetup, getCustomMessages, getId, getMessageBundle, getSeverity, getSeverityLevel, setId, setSeverity
      • Methods inherited from class com.puppycrawl.tools.checkstyle.api.AutomaticBean

        configure, contextualize, getConfiguration, setupChild
    • Field Detail

      • MSG_KEY

        public static final String MSG_KEY
        A key is pointing to the warning message text in "messages.properties" file.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MultipleStringLiteralsExtendedCheck

        public MultipleStringLiteralsExtendedCheck()
        Construct an instance with default values.
    • Method Detail

      • setAllowedDuplicates

        public void setAllowedDuplicates​(int allowedDuplicates)
        Sets the maximum allowed duplicates of a string.
        Parameters:
        allowedDuplicates - The maximum number of duplicates.
      • setIgnoreStringsRegexp

        public final void setIgnoreStringsRegexp​(String ignoreStringsRegexp)
        Sets regexp pattern for ignored strings.
        Parameters:
        ignoreStringsRegexp - regexp pattern for ignored strings
      • setHighlightAllDuplicates

        public final void setHighlightAllDuplicates​(boolean highlightAllDuplicates)
        Sets highlight for all duplicates or only first.
        Parameters:
        highlightAllDuplicates - if true show all duplicates
      • setIgnoreOccurrenceContext

        public final void setIgnoreOccurrenceContext​(String... strRep)
        Adds a set of tokens the check is interested in.
        Parameters:
        strRep - the string representation of the tokens interested in
      • getDefaultTokens

        public int[] getDefaultTokens()
        Specified by:
        getDefaultTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getAcceptableTokens

        public int[] getAcceptableTokens()
        Specified by:
        getAcceptableTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • getRequiredTokens

        public int[] getRequiredTokens()
        Specified by:
        getRequiredTokens in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • visitToken

        public void visitToken​(com.puppycrawl.tools.checkstyle.api.DetailAST ast)
        Overrides:
        visitToken in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • beginTree

        public void beginTree​(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
        Overrides:
        beginTree in class com.puppycrawl.tools.checkstyle.api.AbstractCheck
      • finishTree

        public void finishTree​(com.puppycrawl.tools.checkstyle.api.DetailAST rootAST)
        Overrides:
        finishTree in class com.puppycrawl.tools.checkstyle.api.AbstractCheck