Skip to content

Commit 4e988b3

Browse files
committed
Merge branch 'next' into UseOfBangInspection
2 parents f9c5db7 + d55420f commit 4e988b3

17 files changed

+123
-114
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/ParameterCanBeByValInspection.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@ private bool CanBeChangedToBePassedByValIndividually(ParameterDeclaration parame
9696
&& !IsParameterOfDeclaredLibraryFunction(parameter)
9797
&& (parameter.AsTypeDeclaration == null
9898
|| (!parameter.AsTypeDeclaration.DeclarationType.HasFlag(DeclarationType.ClassModule)
99-
&& parameter.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType
100-
&& parameter.AsTypeDeclaration.DeclarationType != DeclarationType.Enumeration))
99+
&& parameter.AsTypeDeclaration.DeclarationType != DeclarationType.UserDefinedType))
101100
&& !parameter.References.Any(reference => reference.IsAssignment)
102101
&& !IsPotentiallyUsedAsByRefParameter(parameter);
103102
return canPossiblyBeChangedToBePassedByVal;

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+
/// Case Else
109+
/// ' ...
110+
/// End Select
111+
/// End Sub
112+
/// ]]>
113+
/// </example>
44114
public sealed class UnreachableCaseInspection : ParseTreeInspectionBase
45115
{
46116
private readonly IUnreachableCaseInspectorFactory _unreachableCaseInspectorFactory;

Rubberduck.Core/app.config

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@
227227
<setting name="AutoCompleteSettings" serializeAs="Xml">
228228
<value>
229229
<AutoCompleteSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
230-
xmlns:xsd="http://www.w3.org/2001/XMLSchema" IsEnabled="false">
231-
<SmartConcat IsEnabled="false">
230+
xmlns:xsd="http://www.w3.org/2001/XMLSchema" IsEnabled="true">
231+
<SmartConcat IsEnabled="true">
232232
<ConcatVbNewLineModifier>None</ConcatVbNewLineModifier>
233233
<ConcatMaxLines>25</ConcatMaxLines>
234234
</SmartConcat>
235-
<SelfClosingPairs IsEnabled="false" />
236-
<BlockCompletion IsEnabled="false" CompleteOnEnter="false" CompleteOnTab="false" />
235+
<SelfClosingPairs IsEnabled="true" />
236+
<BlockCompletion IsEnabled="true" CompleteOnEnter="true" CompleteOnTab="true" />
237237
</AutoCompleteSettings>
238238
</value>
239239
</setting>

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.

0 commit comments

Comments
 (0)