Details

    • Type: Language-Specification
    • Status: Active
    • Resolution: Unresolved
    • Labels:
    • Message:
      * "xxx" is [redundant|gratuitous] in this context.
    • Highlighting:
      Hide

      Primary: redundant keyword
      Secondary: block delimiters if relevant (e.g. unsafe)

      Show
      Primary: redundant keyword Secondary: block delimiters if relevant (e.g. unsafe )
    • Default Severity:
      Minor
    • Impact:
      Low
    • Likelihood:
      Low
    • Default Quality Profiles:
      Override none

      Description

      Unnecessary keywords simply clutter the code and should be removed. Specifically:

      • partial on type declarations that are completely defined in one place
      • sealed on members of sealed classes
      • unsafe method or block inside construct already marked with unsafe, or when there are no unsafe constructs in the block
      • checked and unchecked blocks with no integral-type arithmetic operations

      Noncompliant Code Example

      public partial class MyClass // Noncompliant
      {
        public virtual void Method()
        {
        }
      }
      
      public sealed class MyOtherClass : MyClass
      {
        public sealed override void Method() // Noncompliant
        {
        }
      }
      

      Compliant Solution

      public class MyClass
      {
        public virtual void Method()
        {
        }
      }
      
      public sealed class MyOtherClass : MyClass
      {
        public override void Method()
        {
        }
      }
      

        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: