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

Unused type parameters should be removed

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      "xxx" is not used in the [method|type|class].
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Default Quality Profiles:
      Sonar way
    • Targeted languages:
      C++, JavaScript
    • Covered Languages:
      C#, Java
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      5min
    • Analysis Scope:
      Main Sources, Test Sources
    • CERT:
      MSC12-CPP.
    • FxCop:
      ReviewUnusedParameters
    • ReSharper:
      UnusedTypeParameter

      Description

      Type parameters that aren't used are dead code, which can only distract and possibly confuse developers during maintenance. Therefore, unused type parameters should be removed.

      Noncompliant Code Example

      public class MoreMath<T>   // Noncompliant; <T> is ignored
      {
        public int Add<T>(int a, int b) // Noncompliant; <T> is ignored
        {
          return a + b; 
        }
      }
      

      Compliant Solution

      public class MoreMath 
      {
        public int Add (int a, int b)
        {
          return a + b; 
        }
      }
      

        Attachments

          Issue Links

          1.
          Java RSPEC-2377 Language-Specification Active Unassigned

            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: