net.sourceforge.pmd.lang.java.rule.design

## Class SwitchDensityRule

- java.lang.Object
- - net.sourceforge.pmd.AbstractPropertySource
  - - net.sourceforge.pmd.lang.rule.AbstractRule
    - - net.sourceforge.pmd.lang.java.rule.AbstractJavaRule
      - - net.sourceforge.pmd.lang.java.rule.AbstractStatisticalJavaRule
        - - net.sourceforge.pmd.lang.java.rule.design.SwitchDensityRule

- All Implemented Interfaces:
    JavaParserVisitor, ImmutableLanguage, StatisticalRule, PropertySource, Rule

      public class SwitchDensityRule
      extends AbstractStatisticalJavaRule

  Author:
    David Dixon-Peugh

    Switch Density - This is the number of statements over the number of cases within a switch. The higher the value, the more work each case is doing.

    Its my theory, that when the Switch Density is high, you should start looking at Subclasses or State Pattern to alleviate the problem.

- - ### Field Summary

    - ### Fields inherited from class net.sourceforge.pmd.AbstractPropertySource

      `propertyDescriptors, propertyValuesByDescriptor`

    - ### Fields inherited from interface net.sourceforge.pmd.lang.rule.stat.StatisticalRule

      `MINIMUM_DESCRIPTOR, SIGMA_DESCRIPTOR, TOP_SCORE_DESCRIPTOR`

    - ### Fields inherited from interface net.sourceforge.pmd.Rule

      `VIOLATION_SUPPRESS_REGEX_DESCRIPTOR, VIOLATION_SUPPRESS_XPATH_DESCRIPTOR`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SwitchDensityRule()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `Object` | `visit(ASTStatement statement, Object data)`
    `Object` | `visit(ASTSwitchLabel switchLabel, Object data)`
    `Object` | `visit(ASTSwitchStatement node, Object data)`

    - ### Methods inherited from class net.sourceforge.pmd.lang.java.rule.AbstractStatisticalJavaRule

      `addDataPoint, apply, getViolationParameters`

    - ### Methods inherited from class net.sourceforge.pmd.lang.java.rule.AbstractJavaRule

      `getDeclaringType, importsPackage, isQualifiedName, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visitAll`

    - ### Methods inherited from class net.sourceforge.pmd.lang.rule.AbstractRule

      `addExample, addRuleChainVisit, addRuleChainVisit, addViolation, addViolation, addViolation, addViolationWithMessage, addViolationWithMessage, addViolationWithMessage, deepCopyValuesTo, end, equals, getDescription, getExamples, getExternalInfoUrl, getLanguage, getMaximumLanguageVersion, getMessage, getMinimumLanguageVersion, getName, getParserOptions, getPriority, getRuleChainVisits, getRuleClass, getRuleSetName, getSince, hashCode, isDeprecated, setDeprecated, setDescription, setExternalInfoUrl, setLanguage, setMaximumLanguageVersion, setMessage, setMinimumLanguageVersion, setName, setPriority, setRuleClass, setRuleSetName, setSince, setUsesDFA, setUsesTypeResolution, start, usesDFA, usesRuleChain, usesTypeResolution`

    - ### Methods inherited from class net.sourceforge.pmd.AbstractPropertySource

      `copyPropertyDescriptors, copyPropertyValues, definePropertyDescriptor, dysfunctionReason, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, setProperty, useDefaultValueFor, usesDefaultValues`

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

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

    - ### Methods inherited from interface net.sourceforge.pmd.Rule

      `addExample, addRuleChainVisit, addRuleChainVisit, end, getDescription, getExamples, getExternalInfoUrl, getLanguage, getMaximumLanguageVersion, getMessage, getMinimumLanguageVersion, getName, getParserOptions, getPriority, getRuleChainVisits, getRuleClass, getRuleSetName, getSince, isDeprecated, setDeprecated, setDescription, setExternalInfoUrl, setLanguage, setMaximumLanguageVersion, setMessage, setMinimumLanguageVersion, setName, setPriority, setRuleClass, setRuleSetName, setSince, setUsesDFA, setUsesTypeResolution, start, usesDFA, usesRuleChain, usesTypeResolution`

    - ### Methods inherited from interface net.sourceforge.pmd.PropertySource

      `definePropertyDescriptor, dysfunctionReason, getPropertiesByPropertyDescriptor, getProperty, getPropertyDescriptor, getPropertyDescriptors, hasDescriptor, ignoredProperties, setProperty, useDefaultValueFor, usesDefaultValues`

- - ### Constructor Detail

    - #### SwitchDensityRule

          public SwitchDensityRule()

  - ### Method Detail

    - #### visit

          public Object visit(ASTSwitchStatement node,
                     Object data)

      Specified by:
        `visit` in interface `JavaParserVisitor`
      Overrides:
        `visit` in class `AbstractJavaRule`

    - #### visit

          public Object visit(ASTStatement statement,
                     Object data)

      Specified by:
        `visit` in interface `JavaParserVisitor`
      Overrides:
        `visit` in class `AbstractJavaRule`

    - #### visit

          public Object visit(ASTSwitchLabel switchLabel,
                     Object data)

      Specified by:
        `visit` in interface `JavaParserVisitor`
      Overrides:
        `visit` in class `AbstractJavaRule`

Copyright © 2002-2013 InfoEther. All Rights Reserved.