Skip to content

Commit 416b81b

Browse files
authored
Merge 4f7e2ed into 9a73fe5
2 parents 9a73fe5 + 4f7e2ed commit 416b81b

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/ImplicitByRefModifierInspection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
1212
/// </summary>
1313
/// <why>
1414
/// VBA parameters are implicitly ByRef, which differs from modern VB (VB.NET) and most other programming languages which are implicitly ByVal.
15-
/// So, explicitly identifing VBA parameter mechanisms (the ByRef and ByVal modifiers) can help surface potentially unexpected language results.
15+
/// So, explicitly identifying VBA parameter mechanisms (the ByRef and ByVal modifiers) can help surface potentially unexpected language results.
1616
/// The inspection does not flag an implicit parameter mechanism for the last parameter of Property mutators (Let or Set).
1717
/// VBA applies a ByVal parameter mechanism to the last parameter in the absence (or presence!) of a modifier.
1818
/// Exception: UserDefinedType parameters must always be passed as ByRef.

Rubberduck.CodeAnalysis/Inspections/Concrete/PublicControlFieldAccessInspection.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
1010
/// Flags MSForms controls being accessed from outside the UserForm that contains them.
1111
/// </summary>
1212
/// <why>
13-
/// MSForms exposes UserForm controls as public fields; accessing these fields outside the UserForm class breaks encapsulation and needlessly couples code with specific form controls.
14-
/// Consider encapsulating the desired values into their own 'model' class, making event handlers in the form manipulate these 'model' properties, and then the calling code can query this encapsulated state instead of querying form controls.
13+
/// MSForms exposes UserForm controls as public fields; accessing these fields outside the UserForm class breaks encapsulation and couples
14+
/// the application logic with specific form controls rather than the data they hold.
15+
/// For a more object-oriented approach and code that can be unit-tested, consider encapsulating the desired values into their own 'model' class,
16+
/// making event handlers in the form manipulate these 'model' properties, then have the code that displayed the form query this encapsulated state as needed.
1517
/// </why>
1618
/// <example hasResult="true">
1719
/// <module name="Module1" type="Standard Module">
@@ -28,6 +30,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
2830
/// End Sub
2931
/// ]]>
3032
/// </module>
33+
/// </example>
3134
/// <example hasResult="false">
3235
/// <module name="Module1" type="Standard Module">
3336
/// <![CDATA[
@@ -45,9 +48,9 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
4548
/// </module>
4649
/// <module name="UserForm1" type="UserForm Module">
4750
/// <![CDATA[
48-
/// ' simple solution: embed the model in the form itself, and expose getters for each desired property.
49-
/// ' > pros: simple to implement.
50-
/// ' > cons: view vs model responsibilities are fuzzy.
51+
/// ' simple solution: embed the model in the form itself, expose a getter procedure for each desired property.
52+
/// ' > pros: simple to implement, silences the inspection!
53+
/// ' > cons: view vs model responsibilities are fuzzy, intellisense get bloated, business logic is still coupled with the UI.
5154
/// Option Explicit
5255
///
5356
/// Public Property Get ExportPath() As String
@@ -60,7 +63,6 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
6063
/// ]]>
6164
/// </module>
6265
/// </example>
63-
/// </example>
6466
/// <example hasResult="false">
6567
/// <module name="Module1" type="Standard Module">
6668
/// <![CDATA[
@@ -79,7 +81,7 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
7981
/// End Sub
8082
/// ]]>
8183
/// </module>
82-
/// <module name="TestMmodel" type="Class Module">
84+
/// <module name="TestModel" type="Class Module">
8385
/// <![CDATA[
8486
/// Option Explicit
8587
/// Private Type TModel
@@ -107,15 +109,16 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
107109
/// </module>
108110
/// <module name="UserForm1" type="UserForm Module">
109111
/// <![CDATA[
110-
/// ' thorough solution: encapsulate the model data into its own data type.
111-
/// ' > pros: easily extended, cleanly separates data from presentation concerns.
112-
/// ' > cons: model-view-presenter architecture requires more modules and can feel "overkill" for simpler scenarios.
112+
/// ' MVP solution: encapsulate the model data into its own data type.
113+
/// ' > pros: easily extended, cleanly separates data from presentation concerns; application logic can be tested independently of the form.
114+
/// ' > cons: Model-View-Presenter architecture requires more modules and can feel/be "overkill" for simpler scenarios.
113115
/// Option Explicit
114116
/// Private Type TView
115117
/// Model As TestModel
116118
/// End Type
117119
/// Private This As TView
118120
///
121+
/// '@Description "Gets or sets Model object for this instance."
119122
/// Public Property Get Model() As TestModel
120123
/// Set Model = This.Model
121124
/// End Property
@@ -125,12 +128,16 @@ namespace Rubberduck.CodeAnalysis.Inspections.Concrete
125128
/// End Property
126129
///
127130
/// Private Sub ExportPathBox_Change()
131+
/// ' the export path has changed; update the model accordingly
128132
/// Model.ExportPath = ExportPathBox.Text
129133
/// End Sub
130134
///
131135
/// Private Sub FileNameBox_Change()
136+
/// ' the file name has changed; update the model accordingly
132137
/// Model.FileName = FileNameBox.Text
133138
/// End Sub
139+
///
140+
/// '...
134141
/// ]]>
135142
/// </module>
136143
/// </example>

Rubberduck.CodeAnalysis/Properties/CodeInspectionDefaults.Designer.cs

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

Rubberduck.CodeAnalysis/Properties/CodeInspectionDefaults.settings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
&lt;CodeInspection Name="ExcelUdfNameIsValidCellReferenceInspection" Severity="Warning" InspectionType="CodeQualityIssues" /&gt;
8585
&lt;CodeInspection Name="EmptyMethodInspection" Severity="Warning" InspectionType="CodeQualityIssues" /&gt;
8686
&lt;CodeInspection Name="ImplementedInterfaceMemberInspection" Severity="Suggestion" InspectionType="CodeQualityIssues" /&gt;
87-
&lt;CodeInspection Name="PublicControlFieldAccessInspection" Severity="Hint" InspectionType="CodeQualityIssues" /&gt;
87+
&lt;CodeInspection Name="PublicControlFieldAccessInspection" Severity="Hint" InspectionType="LanguageOpportunities" /&gt;
8888
&lt;/CodeInspections&gt;
8989
&lt;WhitelistedIdentifiers /&gt;
9090
&lt;RunInspectionsOnSuccessfulParse&gt;true&lt;/RunInspectionsOnSuccessfulParse&gt;

Rubberduck.CodeAnalysis/app.config

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,8 @@
176176
InspectionType="CodeQualityIssues" />
177177
<CodeInspection Name="ImplementedInterfaceMemberInspection" Severity="Suggestion"
178178
InspectionType="CodeQualityIssues" />
179+
<CodeInspection Name="PublicControlFieldAccessInspection" Severity="Hint"
180+
InspectionType="LanguageOpportunities" />
179181
</CodeInspections>
180182
<WhitelistedIdentifiers />
181183
<RunInspectionsOnSuccessfulParse>true</RunInspectionsOnSuccessfulParse>

0 commit comments

Comments
 (0)