Class RulesProfile

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class RulesProfile
    extends java.lang.Object
    implements java.lang.Cloneable
    This class is badly named. It should be "QualityProfile". Indeed it does not relate only to rules but to metric thresholds too.
    • Field Detail

      • SONAR_WAY_NAME

        @Deprecated
        public static final java.lang.String SONAR_WAY_NAME
        Deprecated.
        in 4.2. Use your own constant.
        Name of the default profile "Sonar Way"
        See Also:
        Constant Field Values
      • SONAR_WAY_FINDBUGS_NAME

        @Deprecated
        public static final java.lang.String SONAR_WAY_FINDBUGS_NAME
        Deprecated.
        in 4.2. Use your own constant.
        Name of the default java profile "Sonar way with Findbugs"
        See Also:
        Constant Field Values
      • SUN_CONVENTIONS_NAME

        @Deprecated
        public static final java.lang.String SUN_CONVENTIONS_NAME
        Deprecated.
        in 4.2. Use your own constant.
        Name of the default java profile "Sun checks"
        See Also:
        Constant Field Values
    • Constructor Detail

      • RulesProfile

        @Deprecated
        public RulesProfile()
        Deprecated.
        use the factory method create()
      • RulesProfile

        @Deprecated
        public RulesProfile​(java.lang.String name,
                            java.lang.String language)
        Deprecated.
        since 2.3. Use the factory method create()
      • RulesProfile

        @Deprecated
        public RulesProfile​(java.lang.String name,
                            java.lang.String language,
                            boolean defaultProfile,
                            boolean provided)
        Deprecated.
        since 2.3. Use the factory method create()
    • Method Detail

      • getId

        public java.lang.Integer getId()
      • getName

        public java.lang.String getName()
        Returns:
        the profile name, unique by language.
      • setName

        public RulesProfile setName​(java.lang.String s)
        Set the profile name.
      • getVersion

        @Deprecated
        public int getVersion()
        Deprecated.
        profile versioning is dropped in 4.4. Always returns -1.
      • setVersion

        @Deprecated
        public RulesProfile setVersion​(int version)
        Deprecated.
        profile versioning is dropped in 4.4. Always returns -1.
      • getUsed

        @CheckForNull
        @Deprecated
        public java.lang.Boolean getUsed()
        Deprecated.
        profile versioning is dropped in 4.4. Always returns null.
      • setUsed

        @Deprecated
        public RulesProfile setUsed​(java.lang.Boolean used)
        Deprecated.
        profile versioning is dropped in 4.4. Always returns -1.
      • getActiveRules

        public java.util.List<ActiveRule> getActiveRules()
        Returns:
        the list of active rules
      • getActiveRules

        public java.util.List<ActiveRule> getActiveRules​(boolean acceptDisabledRules)
        Returns:
        the list of active rules
      • setActiveRules

        public void setActiveRules​(java.util.List<ActiveRule> activeRules)
        Set the list of active rules
      • getDefaultProfile

        public java.lang.Boolean getDefaultProfile()
        Returns:
        whether this is the default profile for the language
      • setDefaultProfile

        public void setDefaultProfile​(java.lang.Boolean b)
        Set whether this is the default profile for the language. The default profile is used when none is explicitly defined when auditing a project.
      • getLanguage

        public java.lang.String getLanguage()
        Returns:
        the profile language
      • setLanguage

        public RulesProfile setLanguage​(java.lang.String s)
        Set the profile language
      • getParentName

        @Deprecated
        @CheckForNull
        public java.lang.String getParentName()
        Deprecated.
        in 6.5
        Does nothing.
        Returns:
        null
      • setParentName

        @Deprecated
        public void setParentName​(java.lang.String parentName)
        Deprecated.
        in 6.5
        Does nothing.
      • getActiveRules

        public java.util.List<ActiveRule> getActiveRules​(RulePriority severity)
        Note: disabled rules are excluded.
        Returns:
        the list of active rules for a given severity
      • getActiveRulesByRepository

        public java.util.List<ActiveRule> getActiveRulesByRepository​(java.lang.String repositoryKey)
        Get the active rules of a specific repository. Only enabled rules are selected. Disabled rules are excluded.
      • getActiveRule

        @CheckForNull
        public ActiveRule getActiveRule​(java.lang.String repositoryKey,
                                        java.lang.String ruleKey)
        Note: disabled rules are excluded.
        Returns:
        an active rule from a plugin key and a rule key if the rule is activated, null otherwise
      • getActiveRuleByConfigKey

        @CheckForNull
        public ActiveRule getActiveRuleByConfigKey​(java.lang.String repositoryKey,
                                                   java.lang.String configKey)
        Note: disabled rules are excluded.
      • getActiveRule

        @CheckForNull
        public ActiveRule getActiveRule​(Rule rule)
        Note: disabled rules are excluded.
      • activateRule

        public ActiveRule activateRule​(Rule rule,
                                       @Nullable
                                       RulePriority optionalSeverity)
        Parameters:
        optionalSeverity - if null, then the default rule severity is used
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • clone

        public java.lang.Object clone()
        Overrides:
        clone in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • create

        public static RulesProfile create​(java.lang.String name,
                                          java.lang.String language)