Skip to content

Commit 802548d

Browse files
authored
Merge pull request #5153 from BZngr/4882_UCI_MsgRewording
Improve Unreachable Case Inspection Messages
2 parents 629deec + 3e0520b commit 802548d

13 files changed

+84
-98
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/UnreachableCaseInspection/UnreachableCaseInspection.cs

Lines changed: 72 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
namespace Rubberduck.Inspections.Concrete.UnreachableCaseInspection
1818
{
1919
/// <summary>
20-
/// Flags 'Case' blocks that are semantically unreachable.
20+
/// Flags 'Case' blocks that will never execute.
2121
/// </summary>
2222
/// <why>
2323
/// Unreachable code is certainly unintended, and is probably either redundant, or a bug.
2424
/// </why>
2525
/// <remarks>
2626
/// Not all unreachable 'Case' blocks may be flagged, depending on expression complexity.
2727
/// </remarks>
28-
/// <example hasResults="true">
28+
/// <example hasResult="true">
2929
/// <![CDATA[
3030
/// Private Sub Example(ByVal value As Long)
3131
/// Select Case value
@@ -41,6 +41,76 @@ namespace Rubberduck.Inspections.Concrete.UnreachableCaseInspection
4141
/// End Sub
4242
/// ]]>
4343
/// </example>
44+
/// <example hasResult="true">
45+
/// <![CDATA[
46+
///
47+
/// 'If the cumulative result of multiple 'Case' statements
48+
/// 'cover the entire range of possible values for a data type,
49+
/// 'then all remaining 'Case' statements are unreachable
50+
///
51+
/// Private Sub ExampleAllValuesCoveredIntegral(ByVal value As Long, ByVal result As Long)
52+
/// Select Case result
53+
/// Case Is < 100
54+
/// ' ...
55+
/// Case Is > -100
56+
/// ' ...
57+
/// 'all possible values are covered by preceding 'Case' statements
58+
/// Case value * value ' unreachable
59+
/// ' ...
60+
/// Case value + value ' unreachable
61+
/// ' ...
62+
/// Case Else ' unreachable
63+
/// ' ...
64+
/// End Select
65+
/// End Sub
66+
/// ]]>
67+
/// </example>
68+
/// <example hasResult="false">
69+
/// <![CDATA[
70+
/// Public Enum ProductID
71+
/// Widget = 1
72+
/// Gadget = 2
73+
/// Gizmo = 3
74+
/// End Enum
75+
///
76+
/// Public Sub ExampleEnumCaseElse(ByVal product As ProductID)
77+
///
78+
/// 'Enums are evaluated as the 'Long' data type. So, in this example,
79+
/// 'even though all the ProductID enum values have a 'Case' statement,
80+
/// 'the 'Case Else' will still execute for any value of the 'product'
81+
/// 'parameter that is not a ProductID.
82+
///
83+
/// Select Case product
84+
/// Case Widget
85+
/// ' ...
86+
/// Case Gadget
87+
/// ' ...
88+
/// Case Gizmo
89+
/// ' ...
90+
/// Case Else 'is reachable
91+
/// ' Raise an error for unrecognized/unhandled ProductID
92+
/// End Select
93+
/// End Sub
94+
/// ]]>
95+
/// </example>
96+
/// <example hasResult="true">
97+
/// <![CDATA[
98+
///
99+
/// 'The inspecion flags Range Clauses that are not of the required form:
100+
/// '[x] To [y] where [x] less than or equal to [y]
101+
///
102+
/// Private Sub ExampleInvalidRangeExpression(ByVal value As String)
103+
/// Select Case value
104+
/// Case "Beginning" To "End"
105+
/// ' ...
106+
/// Case "Start" To "Finish" ' unreachable: incorrect form.
107+
/// ' ...
108+
/// CaseElse
109+
/// ' ...
110+
/// End Select
111+
/// End Sub
112+
/// ]]>
113+
/// </example>
44114
public sealed class UnreachableCaseInspection : ParseTreeInspectionBase
45115
{
46116
private readonly IUnreachableCaseInspectorFactory _unreachableCaseInspectorFactory;

Rubberduck.Resources/Inspections/InspectionInfo.Designer.cs

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/Inspections/InspectionInfo.cs.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@ Jestliže může být parametr prázdný, ignorujte výsledek této inspekce; p
229229
<data name="UnhandledOnErrorResumeNextInspection" xml:space="preserve">
230230
<value>Manipulace s chybami by měla být obnovena po použití 'On Error Resume Next'.</value>
231231
</data>
232-
<data name="UnreachableCaseInspection" xml:space="preserve">
233-
<value>Detekuje klauzule případů, které se nikdy nevykonají.</value>
234-
</data>
235232
<data name="EmptyModuleInspection" xml:space="preserve">
236233
<value>Prázdné moduly a třídy buďto odkazují na dosud neimplementovanou funkcionalitu, nebo představují zbytečnou zátěž, která může poškodit udržovatelnost projektu.</value>
237234
</data>

Rubberduck.Resources/Inspections/InspectionInfo.de.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,6 @@ Falls der Parameter 'null' sein kann, bitte dieses Auftreten ignorieren. 'null'
304304
<data name="EmptyModuleInspection" xml:space="preserve">
305305
<value>Leere Module und Klassen weisen entweder auf noch nicht implementierte Funktionalitäten hin oder stellen unnötigen Ballast dar, der die Wartbarkeit eines Projekts behindern kann.</value>
306306
</data>
307-
<data name="UnreachableCaseInspection" xml:space="preserve">
308-
<value>Erkennt "Case"-Klauseln, die nie ausgeführt werden können.</value>
309-
</data>
310307
<data name="UnhandledOnErrorResumeNextInspection" xml:space="preserve">
311308
<value>Fehlerbehandlung sollte nach Verwendung von 'On Error Resume Next' wiederhergestellt werden.</value>
312309
</data>

Rubberduck.Resources/Inspections/InspectionInfo.es.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,6 @@ Si el parámetro puede ser nulo, ignore el resultado de esta inspección; pasar
304304
<data name="EmptyModuleInspection" xml:space="preserve">
305305
<value>Los módulos y clases vacíos apuntan a una funcionalidad aún no implementada o representan un equipaje innecesario que puede perjudicar la mantenibilidad de un proyecto.</value>
306306
</data>
307-
<data name="UnreachableCaseInspection" xml:space="preserve">
308-
<value>Detecta cláusulas de casos que nunca se ejecutarán.</value>
309-
</data>
310307
<data name="UnhandledOnErrorResumeNextInspection" xml:space="preserve">
311308
<value>El manejo de errores se debe restaurar después de usar 'On Error Resume Next'.</value>
312309
</data>

Rubberduck.Resources/Inspections/InspectionInfo.fr.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -304,9 +304,6 @@ Si le paramètre peut être nul, ignorer ce résultat; passer une valeur nulle
304304
<data name="EmptyModuleInspection" xml:space="preserve">
305305
<value>Les modules et classes vides démontrent des fonctionnalités pas encore implémentées ou représentent un fardeau non nécessaire pouvant nuire à la maintenance du projet.</value>
306306
</data>
307-
<data name="UnreachableCaseInspection" xml:space="preserve">
308-
<value>Détecte les clauses 'Case' qui ne peuvent être exécutées.</value>
309-
</data>
310307
<data name="UnhandledOnErrorResumeNextInspection" xml:space="preserve">
311308
<value>La gestion d'erreurs devrait être restaurée après l'utilisation de 'On Error Resume Next'</value>
312309
</data>

Rubberduck.Resources/Inspections/InspectionInfo.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ If the parameter can be null, ignore this inspection result; passing a null valu
305305
<value>Empty modules and classes either point to not yet implemented functionality or represent unnecessary baggage that can hurt the maintainability of a project.</value>
306306
</data>
307307
<data name="UnreachableCaseInspection" xml:space="preserve">
308-
<value>Detects Case Clauses that will never execute. </value>
308+
<value>A 'Case' condition either always evaluates to False, causes a run-time error, or the cumulative effect of prior 'Case' statements represents all possible values or a superset of the 'Case' statement's values. As a result, the 'Case' block will never execute and is "dead code", or the 'Case' statement is a run-time error waiting to happen. Consider removing, reordering, or modifying the 'Case' statement.</value>
309309
</data>
310310
<data name="UnhandledOnErrorResumeNextInspection" xml:space="preserve">
311311
<value>Error handling should be restored after using 'On Error Resume Next'.</value>

Rubberduck.Resources/Inspections/InspectionResults.Designer.cs

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Rubberduck.Resources/Inspections/InspectionResults.cs.resx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -303,18 +303,6 @@
303303
<data name="EmptyModuleInspection" xml:space="preserve">
304304
<value>Modul/třída {0} je prázdná.</value>
305305
</data>
306-
<data name="UnreachableCaseInspection" xml:space="preserve">
307-
<value>Není schopno dosáhnout na 'Case' klauzuli '{0}'</value>
308-
</data>
309-
<data name="UnreachableCaseInspection_CaseElse" xml:space="preserve">
310-
<value>Nedosažitelný 'Case Else': Všechny potřebné hodnoty jsou vyřešeny předchozím 'Case' příkazem/příkazy</value>
311-
</data>
312-
<data name="UnreachableCaseInspection_TypeMismatch" xml:space="preserve">
313-
<value>Neplatný Typ: 'Case' Příkaz nemůže být vyhodnocen jako typ příkazu 'Select'</value>
314-
</data>
315-
<data name="UnreachableCaseInspection_Unreachable" xml:space="preserve">
316-
<value>Nedosažitelné: 'Case' příkaz je vyřešen předchozím 'Case' příkazem/příkazy</value>
317-
</data>
318306
<data name="UnhandledOnErrorResumeNextInspection" xml:space="preserve">
319307
<value>Errory jsou ignorovány, avšak už nikdy neřešeny</value>
320308
</data>
@@ -336,12 +324,6 @@
336324
<data name="ObsoleteCallingConventionInspection" xml:space="preserve">
337325
<value>'{0}' je deklarováno zastaralou 'CDecl' volací konvencí.</value>
338326
</data>
339-
<data name="UnreachableCaseInspection_InherentlyUnreachable" xml:space="preserve">
340-
<value>Nedostupné: Case Statement obsahuje klauzuli(e) o neplatném rozsahu.</value>
341-
</data>
342-
<data name="UnreachableCaseInspection_Overflow" xml:space="preserve">
343-
<value>Nedostupné: Case Statement způsobí Run-time chybu č. 6 (Přetečení)</value>
344-
</data>
345327
<data name="DuplicatedAnnotationInspection" xml:space="preserve">
346328
<value>Anotace '{0}' je duplikována.</value>
347329
</data>

Rubberduck.Resources/Inspections/InspectionResults.de.resx

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -305,18 +305,6 @@
305305
<data name="EmptyModuleInspection" xml:space="preserve">
306306
<value>Modul/Klasse {0} ist leer.</value>
307307
</data>
308-
<data name="UnreachableCaseInspection" xml:space="preserve">
309-
<value>Die Case-Klausel '{0}' kann nicht erreicht werden</value>
310-
</data>
311-
<data name="UnreachableCaseInspection_CaseElse" xml:space="preserve">
312-
<value>Nicht erreichbares Case Else: Alle möglichen Werte sind durch vorangehende Klausel(n) abgedeckt.</value>
313-
</data>
314-
<data name="UnreachableCaseInspection_TypeMismatch" xml:space="preserve">
315-
<value>Inakzeptabler Typ: Die Case-Anweisung kann nicht als derselbe Typ wie die Select-Anweisung ausgewertet werden.</value>
316-
</data>
317-
<data name="UnreachableCaseInspection_Unreachable" xml:space="preserve">
318-
<value>Unerreichbar: Case-Klausel ist bereits von anderen Klausel(n) abgehandelt.</value>
319-
</data>
320308
<data name="UnhandledOnErrorResumeNextInspection" xml:space="preserve">
321309
<value>Fehler werden ignoriert aber nie wieder behandelt.</value>
322310
</data>
@@ -338,12 +326,6 @@
338326
<data name="ObsoleteCallingConventionInspection" xml:space="preserve">
339327
<value>'{0}' wurde mit der unter Windows nicht erlaubten 'CDecl'-Aufrufkonvention deklariert.</value>
340328
</data>
341-
<data name="UnreachableCaseInspection_InherentlyUnreachable" xml:space="preserve">
342-
<value>Unerreichbar: Case-Klausel enthält unzulässige Bereichsdefinition(en).</value>
343-
</data>
344-
<data name="UnreachableCaseInspection_Overflow" xml:space="preserve">
345-
<value>Unerreichbar: Case-Klausel wird einen Laufzeitfehler 6 - 'Überlauf' erzeugen.</value>
346-
</data>
347329
<data name="DuplicatedAnnotationInspection" xml:space="preserve">
348330
<value>Annotation '{0}' wurde mehrfach spezifiziert.</value>
349331
</data>

0 commit comments

Comments
 (0)