Uploaded image for project: 'Rules Repository'
  1. Rules Repository
  2. RSPEC-3376

Attribute, EventArgs, and Exception type names should end with the type being extended

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Make this class name end with "xxx".
    • Highlighting:
      Hide

      class name

      Show
      class name
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      VB.Net
    • Covered Languages:
      C#
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources
    • FxCop:
      CA1710

      Description

      Adherence to the standard naming conventions makes your code not only more readable, but more usable. For instance, class FirstAttribute : Attribute can be used simply with First, but you must use the full name for class AttributeOne : Attribute.

      This rule raises an issue when classes extending Attribute, EventArgs, or Exception, do not end with their parent class names.

      Noncompliant Code Example

      class AttributeOne : Attribute  // Noncompliant
      {
      }
      

      Compliant Solution

      class FirstAttribute : Attribute 
      {
      }
      

      Exceptions

      If a class' direct base class doesn't follow the convention, then no issue is reported on the class itself, regardless of whether or not it conforms to the convention.

      class Timeout : Exception // Noncompliant
      {
      }
      class ExtendedTimeout : Timeout // Ignored; doesn't conform to convention, but the direct base doesn't conform either
      {
      }
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            ann.campbell.2 Ann Campbell
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated: