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

Method signatures should not contain nested generic types

    XMLWordPrintable

    Details

    • Type: Code Smell Detection
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      Refactor this method to remove the nested type argument.
    • Highlighting:
      Hide

      The nested type argument in the method declaration

      Show
      The nested type argument in the method declaration
    • Default Severity:
      Major
    • Impact:
      Low
    • Likelihood:
      High
    • Covered Languages:
      C#
    • Irrelevant for Languages:
      ABAP, C, C++, Cobol, CSS, Flex, HTML, Java, JavaScript, Objective-C, PHP, PL/I, PL/SQL, Python, RPG, Swift, T-SQL, TypeScript, VB.Net, VB6, XML
    • Remediation Function:
      Constant/Issue
    • Constant Cost:
      30min
    • Analysis Scope:
      Main Sources, Test Sources
    • FxCop:
      DoNotNestGenericTypesInMemberSignatures, CA1006

      Description

      A nested type is a type argument that is also a generic type. Calling a method with such a nested type argument requires complicated and confusing code. It should be avoided as much as possible.

      Noncompliant Code Example

      using System;
      using System.Collections.Generic;
      
      namespace MyLibrary
      {
        public class Foo
        {
          public void DoSomething(ICollection<ICollection<int>> outerCollect) // Noncompliant
          {
          }
        }
      }
      

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              jeanchristophe.collet Jean-Christophe Collet (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated: