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

Strings or integral types should be used for indexers

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Use string, integral, index or range type here, or refactor this indexer into a method.
    • Highlighting:
      Hide

      this[xxx]

      Show
      this [xxx]
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Covered Languages:
      C#
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      20min
    • Analysis Scope:
      Main Sources, Test Sources
    • FxCop:
      UseIntegralOrStringArgumentForIndexers , CA1043

      Description

      Strings and integral types are typically used as indexers. When some other type is required, it typically indicates design problems, and potentially a situation where a method should be used instead.

      Noncompliant Code Example

      public int this[MyCustomClass index]  // Noncompliant
      {  
          // get and set accessors  
      }
      

        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: