Dimming unused parameters

Topics: General
May 29, 2014 at 4:49 PM
I would probably find it useful if unused parameters of methods were too dimmed. Any opinions on this?
Coordinator
Jun 5, 2014 at 3:17 PM
We have a giant list of things that could be dimmed, but we're unlikely to be able to implement them all - you could implement your own Diagnostic for this however :)
Jun 5, 2014 at 3:44 PM
Fair enough. Do you think you could mention couple of items from that giant list? :)
Coordinator
Jun 10, 2014 at 7:56 PM
Edited Jun 10, 2014 at 9:09 PM
Here is a list of redundancies in code that you could imagine detecting, dimming and offering to remove that someone on our team put together 2 years ago. It has not been updated for new language features:
  • Using directive
  • Namespace/type qualifier
  • Casts, safe casts
  • Redundant cast to delegate before invocation
  • Redundant explicit Invoke method
  • Type arguments
  • Arguments to optional parameters
  • Names of named arguments
  • Type in an array creation expression
  • Size in an array creation expression
  • Types of parameters in lambda
  • Explicit delegate constructor
  • Explicit nullable constructor
  • Explicit call to base constructor
  • Explicit default constructor declaration
  • Comparison with true
  • Unassigned struct creation expressions
  • ToString before concatenation
  • ToString invoked on string
  • Empty namespace declaration
  • Empty else block
  • Empty switch block
  • Switch label adjacent to default
  • Empty finally block
  • Catch-throw block
  • Empty catch(ThreadAbortException) clause
  • If with constant true condition
  • Redundant control flow statement: return, break, continue, goto
  • Parameter is unused except possibly for recursion (cross-method?)
  • Private method is unused except possibly for cross-method recursion
  • Type parameter of a method is unused
  • Redundant generic constraint
  • Redundant implemented interface
  • Redundant base/MyBase/MyClass qualifier
  • Null or empty concatenated string
  • Multiplication by 1
  • Addition/subtraction of 0 (careful with +/- 0.0)
  • Redundant flags in bitwise enum operations
  • Redundant argument to string.Format or related method
  • Redundant string.Format or related method for 0/1 arguments
  • Redundant intermediate string.Format in Console.WriteLine or similar method
  • Redundant private method overload redirecting to method with optional parameters
  • Redundant 'new' modifier
  • Redundant override
  • Redundant abstract override
  • Redundant check before assignment
  • Redundant 'is' operator in (x is string && x is IEnumerable)
  • Redundant null check/HasValue in (x != null && x is string)
  • Redundant comparisons with boundary values
  • Redundant If/ternary with identical branches
  • Redundant If/ternary with true/false branches
  • Redundant 'where true' clause or Where(x => true) method invocation

C#-specific

  • Parameter list in anonymous method
  • Empty nested object initializer
  • Empty object initializer
  • Empty parentheses before object/collection initializer
  • Redundant @ before identifier
  • Redundant @ before string
  • Redundant explicit interface implementaion
  • Redundant 'goto case' statements
  • Redundant sections in switch statement containing only break
  • Redundant semicolon after statement of after type declaration
  • Null added/subtracted delegate

VB-specific

  • Redundant Module qualifier
  • Redundant comma in invocation
  • Redundant default property name
  • Redundant ElementAtOrDefault
  • Redundant Call keywords
  • Redundant [ ] around identifier