S1123 — "Obsolete" attributes should include explanations

Language
VB.NET
Type
Code smell
Severity
Major
Tags
obsolete, bad-practice

Why is this an issue?

The Obsolete attribute can be applied with or without a message argument. Marking something Obsolete without including advice on why it’s obsolete or what to use instead will lead maintainers to waste time trying to figure those things out.

Noncompliant code example


Public Class Car

    <Obsolete>  ' Noncompliant
    Public Sub CrankEngine(Turns As Integer)
        ' ...
    End Sub

End Class

Compliant solution


Public Class Car

    <Obsolete("Replaced by the automatic starter")>
    Public Sub CrankEngine(Turns As Integer)
        ' ...
    End Sub

End Class

↑ Back to top