Skip to content

Commit f0d9c81

Browse files
authored
Style cop (#646)
1 parent 0b70456 commit f0d9c81

File tree

147 files changed

+3234
-1317
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+3234
-1317
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
14
using System.Reflection;
25
using System.Runtime.CompilerServices;
36
using System.Runtime.InteropServices;
@@ -6,5 +9,4 @@
69
[assembly: AssemblyCompany("nanoFramework Contributors")]
710
[assembly: AssemblyCopyright("Copyright(c).NET Foundation and Contributors")]
811

9-
[assembly: ComVisible(false)]
10-
12+
[assembly: ComVisible(false)]

devices/ServoMotor/ServoMotor.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public ServoMotor(
3434
}
3535

3636
/// <summary>
37-
/// Sets calibration parameters
37+
/// Sets calibration parameters.
3838
/// </summary>
3939
/// <param name="maximumAngle">The maximum angle the servo motor can move represented as a value between 0 and 360.</param>
4040
/// <param name="minimumPulseWidthMicroseconds">The minimum pulse width, in microseconds, that represent an angle for 0 degrees.</param>
@@ -82,7 +82,7 @@ public void WriteAngle(double angle)
8282
throw new ArgumentOutOfRangeException(nameof(angle));
8383
}
8484

85-
WritePulseWidth((int)(_angleToMicroseconds * angle + _minimumPulseWidthMicroseconds));
85+
WritePulseWidth((int)((_angleToMicroseconds * angle) + _minimumPulseWidthMicroseconds));
8686
}
8787

8888
/// <summary>
@@ -99,7 +99,7 @@ public void WritePulseWidth(int microseconds)
9999
public void Dispose()
100100
{
101101
_pwmChannel?.Dispose();
102-
_pwmChannel = null!;
102+
_pwmChannel = null;
103103
}
104104
}
105105
}

devices/ServoMotor/ServoMotor.nfproj

+9-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
1919
<DocumentationFile>bin\$(Configuration)\Iot.Device.ServoMotor.xml</DocumentationFile>
2020
<LangVersion>9.0</LangVersion>
21+
<StyleCopTreatErrorsAsWarnings>false</StyleCopTreatErrorsAsWarnings>
2122
</PropertyGroup>
2223
<PropertyGroup>
2324
<SignAssembly>true</SignAssembly>
@@ -63,4 +64,11 @@
6364
<Error Condition="!Exists('packages\Nerdbank.GitVersioning.3.5.119\build\Nerdbank.GitVersioning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Nerdbank.GitVersioning.3.5.119\build\Nerdbank.GitVersioning.targets'))" />
6465
</Target>
6566
<Import Project="packages\Nerdbank.GitVersioning.3.5.119\build\Nerdbank.GitVersioning.targets" Condition="Exists('packages\Nerdbank.GitVersioning.3.5.119\build\Nerdbank.GitVersioning.targets')" />
66-
</Project>
67+
<Import Project="packages\StyleCop.MSBuild.6.2.0\build\StyleCop.MSBuild.targets" Condition="Exists('packages\StyleCop.MSBuild.6.2.0\build\StyleCop.MSBuild.targets')" />
68+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
69+
<PropertyGroup>
70+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
71+
</PropertyGroup>
72+
<Error Condition="!Exists('packages\StyleCop.MSBuild.6.2.0\build\StyleCop.MSBuild.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\StyleCop.MSBuild.6.2.0\build\StyleCop.MSBuild.targets'))" />
73+
</Target>
74+
</Project>

devices/ServoMotor/Settings.StyleCop

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<StyleCopSettings Version="105">
2+
<Analyzers>
3+
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
4+
<Rules>
5+
<Rule Name="FileHeaderMustContainFileName">
6+
<RuleSettings>
7+
<BooleanProperty Name="Enabled">False</BooleanProperty>
8+
</RuleSettings>
9+
</Rule>
10+
<Rule Name="FileHeaderMustHaveValidCompanyText">
11+
<RuleSettings>
12+
<BooleanProperty Name="Enabled">False</BooleanProperty>
13+
</RuleSettings>
14+
</Rule>
15+
<Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
16+
<RuleSettings>
17+
<BooleanProperty Name="Enabled">False</BooleanProperty>
18+
</RuleSettings>
19+
</Rule>
20+
<Rule Name="PropertyDocumentationMustHaveValueText">
21+
<RuleSettings>
22+
<BooleanProperty Name="Enabled">True</BooleanProperty>
23+
</RuleSettings>
24+
</Rule>
25+
<Rule Name="DocumentationTextMustBeginWithACapitalLetter">
26+
<RuleSettings>
27+
<BooleanProperty Name="Enabled">True</BooleanProperty>
28+
</RuleSettings>
29+
</Rule>
30+
<Rule Name="DocumentationTextMustEndWithAPeriod">
31+
<RuleSettings>
32+
<BooleanProperty Name="Enabled">True</BooleanProperty>
33+
</RuleSettings>
34+
</Rule>
35+
<Rule Name="FileHeaderMustShowCopyright">
36+
<RuleSettings>
37+
<BooleanProperty Name="Enabled">False</BooleanProperty>
38+
</RuleSettings>
39+
</Rule>
40+
<Rule Name="FileHeaderMustHaveCopyrightText">
41+
<RuleSettings>
42+
<BooleanProperty Name="Enabled">False</BooleanProperty>
43+
</RuleSettings>
44+
</Rule>
45+
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
46+
<RuleSettings>
47+
<BooleanProperty Name="Enabled">False</BooleanProperty>
48+
</RuleSettings>
49+
</Rule>
50+
<Rule Name="DocumentationTextMustContainWhitespace">
51+
<RuleSettings>
52+
<BooleanProperty Name="Enabled">False</BooleanProperty>
53+
</RuleSettings>
54+
</Rule>
55+
</Rules>
56+
<AnalyzerSettings>
57+
<BooleanProperty Name="IgnorePrivates">True</BooleanProperty>
58+
<BooleanProperty Name="IgnoreInternals">True</BooleanProperty>
59+
</AnalyzerSettings>
60+
</Analyzer>
61+
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
62+
<Rules>
63+
<Rule Name="PrefixLocalCallsWithThis">
64+
<RuleSettings>
65+
<BooleanProperty Name="Enabled">False</BooleanProperty>
66+
</RuleSettings>
67+
</Rule>
68+
<Rule Name="PrefixCallsCorrectly">
69+
<RuleSettings>
70+
<BooleanProperty Name="Enabled">False</BooleanProperty>
71+
</RuleSettings>
72+
</Rule>
73+
</Rules>
74+
<AnalyzerSettings />
75+
</Analyzer>
76+
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
77+
<Rules>
78+
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
79+
<RuleSettings>
80+
<BooleanProperty Name="Enabled">False</BooleanProperty>
81+
</RuleSettings>
82+
</Rule>
83+
<Rule Name="ElementsMustAppearInTheCorrectOrder">
84+
<RuleSettings>
85+
<BooleanProperty Name="Enabled">False</BooleanProperty>
86+
</RuleSettings>
87+
</Rule>
88+
<Rule Name="ElementsMustBeOrderedByAccess">
89+
<RuleSettings>
90+
<BooleanProperty Name="Enabled">False</BooleanProperty>
91+
</RuleSettings>
92+
</Rule>
93+
</Rules>
94+
<AnalyzerSettings />
95+
</Analyzer>
96+
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
97+
<Rules>
98+
<Rule Name="FieldNamesMustNotBeginWithUnderscore">
99+
<RuleSettings>
100+
<BooleanProperty Name="Enabled">False</BooleanProperty>
101+
</RuleSettings>
102+
</Rule>
103+
<Rule Name="FieldNamesMustNotUseHungarianNotation">
104+
<RuleSettings>
105+
<BooleanProperty Name="Enabled">False</BooleanProperty>
106+
</RuleSettings>
107+
</Rule>
108+
</Rules>
109+
<AnalyzerSettings />
110+
</Analyzer>
111+
</Analyzers>
112+
</StyleCopSettings>

devices/ServoMotor/packages.config

+1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
<package id="nanoFramework.CoreLibrary" version="1.12.0" targetFramework="netnano1.0" />
44
<package id="nanoFramework.System.Device.Pwm" version="1.0.1" targetFramework="netnano1.0" />
55
<package id="Nerdbank.GitVersioning" version="3.5.119" developmentDependency="true" targetFramework="netnano1.0" />
6+
<package id="StyleCop.MSBuild" version="6.2.0" targetFramework="netnano1.0" developmentDependency="true" />
67
</packages>

devices/ServoMotor/packages.lock.json

+6
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
"requested": "[3.5.119, 3.5.119]",
2020
"resolved": "3.5.119",
2121
"contentHash": "x8k4zV6YKZA5Rr810439lG9NngdbyPtFv0QpIYz32m1Im59kvSbEHO8gKGZoNvsfZSquayjEDUCa8acbut372g=="
22+
},
23+
"StyleCop.MSBuild": {
24+
"type": "Direct",
25+
"requested": "[6.2.0, 6.2.0]",
26+
"resolved": "6.2.0",
27+
"contentHash": "6J51Kt5X+Os+Ckp20SFP1SlLu3tZl+3qBhCMtJUJqGDgwSr4oHT+eg545hXCdp07tRB/8nZfXTOBDdA1XXvjUw=="
2228
}
2329
}
2430
}
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
14
using System.Reflection;
25
using System.Runtime.CompilerServices;
36
using System.Runtime.InteropServices;
@@ -6,5 +9,4 @@
69
[assembly: AssemblyCompany("nanoFramework Contributors")]
710
[assembly: AssemblyCopyright("Copyright(c).NET Foundation and Contributors")]
811

9-
[assembly: ComVisible(false)]
10-
12+
[assembly: ComVisible(false)]
+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
<StyleCopSettings Version="105">
2+
<Analyzers>
3+
<Analyzer AnalyzerId="StyleCop.CSharp.DocumentationRules">
4+
<Rules>
5+
<Rule Name="FileHeaderMustContainFileName">
6+
<RuleSettings>
7+
<BooleanProperty Name="Enabled">False</BooleanProperty>
8+
</RuleSettings>
9+
</Rule>
10+
<Rule Name="FileHeaderMustHaveValidCompanyText">
11+
<RuleSettings>
12+
<BooleanProperty Name="Enabled">False</BooleanProperty>
13+
</RuleSettings>
14+
</Rule>
15+
<Rule Name="FileHeaderFileNameDocumentationMustMatchTypeName">
16+
<RuleSettings>
17+
<BooleanProperty Name="Enabled">False</BooleanProperty>
18+
</RuleSettings>
19+
</Rule>
20+
<Rule Name="PropertyDocumentationMustHaveValueText">
21+
<RuleSettings>
22+
<BooleanProperty Name="Enabled">True</BooleanProperty>
23+
</RuleSettings>
24+
</Rule>
25+
<Rule Name="DocumentationTextMustBeginWithACapitalLetter">
26+
<RuleSettings>
27+
<BooleanProperty Name="Enabled">True</BooleanProperty>
28+
</RuleSettings>
29+
</Rule>
30+
<Rule Name="DocumentationTextMustEndWithAPeriod">
31+
<RuleSettings>
32+
<BooleanProperty Name="Enabled">True</BooleanProperty>
33+
</RuleSettings>
34+
</Rule>
35+
<Rule Name="FileHeaderMustShowCopyright">
36+
<RuleSettings>
37+
<BooleanProperty Name="Enabled">False</BooleanProperty>
38+
</RuleSettings>
39+
</Rule>
40+
<Rule Name="FileHeaderMustHaveCopyrightText">
41+
<RuleSettings>
42+
<BooleanProperty Name="Enabled">False</BooleanProperty>
43+
</RuleSettings>
44+
</Rule>
45+
<Rule Name="ElementDocumentationMustBeSpelledCorrectly">
46+
<RuleSettings>
47+
<BooleanProperty Name="Enabled">False</BooleanProperty>
48+
</RuleSettings>
49+
</Rule>
50+
<Rule Name="DocumentationTextMustContainWhitespace">
51+
<RuleSettings>
52+
<BooleanProperty Name="Enabled">False</BooleanProperty>
53+
</RuleSettings>
54+
</Rule>
55+
</Rules>
56+
<AnalyzerSettings>
57+
<BooleanProperty Name="IgnorePrivates">True</BooleanProperty>
58+
<BooleanProperty Name="IgnoreInternals">True</BooleanProperty>
59+
</AnalyzerSettings>
60+
</Analyzer>
61+
<Analyzer AnalyzerId="StyleCop.CSharp.ReadabilityRules">
62+
<Rules>
63+
<Rule Name="PrefixLocalCallsWithThis">
64+
<RuleSettings>
65+
<BooleanProperty Name="Enabled">False</BooleanProperty>
66+
</RuleSettings>
67+
</Rule>
68+
<Rule Name="PrefixCallsCorrectly">
69+
<RuleSettings>
70+
<BooleanProperty Name="Enabled">False</BooleanProperty>
71+
</RuleSettings>
72+
</Rule>
73+
</Rules>
74+
<AnalyzerSettings />
75+
</Analyzer>
76+
<Analyzer AnalyzerId="StyleCop.CSharp.OrderingRules">
77+
<Rules>
78+
<Rule Name="UsingDirectivesMustBePlacedWithinNamespace">
79+
<RuleSettings>
80+
<BooleanProperty Name="Enabled">False</BooleanProperty>
81+
</RuleSettings>
82+
</Rule>
83+
<Rule Name="ElementsMustAppearInTheCorrectOrder">
84+
<RuleSettings>
85+
<BooleanProperty Name="Enabled">False</BooleanProperty>
86+
</RuleSettings>
87+
</Rule>
88+
<Rule Name="ElementsMustBeOrderedByAccess">
89+
<RuleSettings>
90+
<BooleanProperty Name="Enabled">False</BooleanProperty>
91+
</RuleSettings>
92+
</Rule>
93+
</Rules>
94+
<AnalyzerSettings />
95+
</Analyzer>
96+
<Analyzer AnalyzerId="StyleCop.CSharp.NamingRules">
97+
<Rules>
98+
<Rule Name="FieldNamesMustNotBeginWithUnderscore">
99+
<RuleSettings>
100+
<BooleanProperty Name="Enabled">False</BooleanProperty>
101+
</RuleSettings>
102+
</Rule>
103+
<Rule Name="FieldNamesMustNotUseHungarianNotation">
104+
<RuleSettings>
105+
<BooleanProperty Name="Enabled">False</BooleanProperty>
106+
</RuleSettings>
107+
</Rule>
108+
</Rules>
109+
<AnalyzerSettings />
110+
</Analyzer>
111+
</Analyzers>
112+
</StyleCopSettings>

0 commit comments

Comments
 (0)