Skip to content

Commit 9681a91

Browse files
authored
Update Analyzers and fix TestsRuleset package (#17)
- Fixed TestsRuleset package so the main `.globalconfig` is inherited and then overwritten by the tests-specific rules and not the other way around - Updated `SonarAnalyzer.CSharp` to latest minor version (8.56.0.67649) - Changed from `StyleCop.Analyzers` package to `StyleCop.Analyzers.Unstable` and update to latest available version (1.2.0.556) - Changed `.globalconfig` file names to match NuGet package names as recommended by Microsoft - Currently active `.globalconfig` is now linked in the solution explorer and therefore quickly accessible from within the IDE
1 parent 9933359 commit 9681a91

10 files changed

Lines changed: 121 additions & 811 deletions

.github/workflows/create-release.yml

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,42 @@ name: Create Release
33
on:
44
workflow_dispatch:
55
inputs:
6-
version_type:
6+
versioning_phase:
77
type: choice
8-
description: Semantic Version Type
8+
description: Versioning Phase
9+
default: stable
910
options:
10-
- automatic
11+
- alpha
12+
- beta
13+
- rc
14+
- stable
15+
16+
bump_version_number:
17+
type: choice
18+
description: Bump Version Number
19+
default: consecutive
20+
options:
21+
- consecutive
1122
- patch
1223
- minor
1324
- major
1425

15-
pre_release:
16-
type: choice
17-
description: Stage
18-
options:
19-
- stable
20-
- rc
21-
- beta
22-
- alpha
26+
is_dry_run:
27+
type: boolean
28+
description: Dry Run
2329

2430
jobs:
2531
release-it:
2632
runs-on: ubuntu-latest
2733
steps:
28-
- uses: tibdex/github-app-token@v1
34+
- uses: tibdex/github-app-token@v2
2935
id: generate-token
3036
with:
3137
app_id: ${{ secrets.RELEASE_BOT_APP_ID }}
3238
private_key: ${{ secrets.RELEASE_BOT_APP_PRIVATE_KEY }}
3339

3440
- name: checkout
35-
uses: actions/checkout@v3
41+
uses: actions/checkout@v4
3642
with:
3743
token: ${{ steps.generate-token.outputs.token }}
3844
# we need everything so release-it can compare the current version with the latest tag
@@ -43,26 +49,30 @@ jobs:
4349
git config user.name "GitHub Release Bot"
4450
git config user.email release-bot@neolution.ch
4551
46-
- name: install @release-it/keep-a-changelog
52+
- name: install release-it with plugins
4753
run: npm install -g release-it @release-it/keep-a-changelog
4854

4955
- name: run release-it
5056
run: |
5157
params=()
5258
53-
if [[ ${{ github.event.inputs.version_type }} != "automatic" ]]; then
54-
params+=(${{ github.event.inputs.version_type }})
59+
if [[ ${{ github.event.inputs.bump_version_number }} != "consecutive" ]]; then
60+
params+=(${{ github.event.inputs.bump_version_number }})
5561
fi
5662
57-
if [[ ${{ github.event.inputs.pre_release }} != "stable" ]]; then
58-
params+=(--preRelease=${{ github.event.inputs.pre_release }})
63+
if [[ ${{ github.event.inputs.versioning_phase }} != "stable" ]]; then
64+
params+=(--preRelease=${{ github.event.inputs.versioning_phase }})
5965
params+=(--plugins.@release-it/keep-a-changelog.keepUnreleased)
6066
params+=(--no-plugins.@release-it/keep-a-changelog.strictLatest)
6167
fi
6268
69+
if [[ ${{ github.event.inputs.is_dry_run }} == "true" ]]; then
70+
params+=(--dry-run)
71+
fi
72+
6373
params+=(--ci)
6474
6575
echo "command: release-it ${params[@]}"
6676
release-it "${params[@]}"
6777
env:
68-
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
78+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}

.release-it.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"filename": "CHANGELOG.md",
1515
"addVersionUrl": true,
1616
"addUnreleased": true,
17-
"strictLatest": true
17+
"strictLatest": false
1818
}
1919
},
2020
"hooks": {

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,37 @@ and adheres to a project-specific [Versioning](/README.md).
77

88
## [Unreleased]
99

10+
### Fixed
11+
12+
- Fixed TestsRuleset package so the main `.globalconfig` is inherited and then overwritten by the tests-specific rules and not the other way around
13+
14+
### Changed
15+
16+
- Updated `SonarAnalyzer.CSharp` to latest minor version (8.56.0.67649)
17+
- Changed from `StyleCop.Analyzers` package to `StyleCop.Analyzers.Unstable` and update to latest available version (1.2.0.556)
18+
- Changed `.globalconfig` file names to match NuGet package names as recommended by Microsoft
19+
- Currently active `.globalconfig` is now linked in the solution explorer and therefore quickly accessible from within the IDE
20+
21+
### Added
22+
23+
- S1133: Deprecated code should be removed
24+
- S2094: Classes should not be empty
25+
- S2166: Classes named like "Exception" should extend "Exception" or a subclass
26+
- S2198: Silly mathematical comparisons should not be made
27+
- S2445: Blocks should be synchronized on read-only fields
28+
- S2970: Assertions should be complete
29+
- S3063: "StringBuilder" data should be used
30+
- S3398: "private" methods called only by inner classes should be moved to those classes
31+
- S3878: Arrays should not be created for params parameters
32+
- S4545: "DebuggerDisplayAttribute" strings should reference existing members
33+
- S4663: Comments should not be empty
34+
- S5856: Regular expressions should be syntactically valid
35+
- CA2000: Dispose objects before losing scopes
36+
37+
### Removed
38+
39+
- SA1518: Use line endings correctly at end of file
40+
1041
## [3.0.5] - 2023-09-28
1142

1243
### Fixed

Neolution.CodeAnalysis.TestsRuleset.nuspec

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<developmentDependency>true</developmentDependency>
1414
<dependencies>
15-
<dependency id="StyleCop.Analyzers" version="1.2.0-beta.435" />
16-
<dependency id="SonarAnalyzer.CSharp" version="8.52.0.60960" />
15+
<dependency id="StyleCop.Analyzers.Unstable" version="1.2.0.556" />
16+
<dependency id="SonarAnalyzer.CSharp" version="8.56.0.67649" />
1717
</dependencies>
1818
</metadata>
1919
<files>
2020
<file src="build\Neolution.CodeAnalysis.TestsRuleset.props" target="build\Neolution.CodeAnalysis.TestsRuleset.props" />
21-
<file src="build\Neolution.Tests.globalconfig" target="build\Neolution.Tests.globalconfig" />
21+
<file src="build\Neolution.CodeAnalysis.globalconfig" target="build\Neolution.CodeAnalysis.globalconfig" />
22+
<file src="build\Neolution.CodeAnalysis.TestsRuleset.globalconfig" target="build\Neolution.CodeAnalysis.TestsRuleset.globalconfig" />
2223
<file src="build\stylecop.json" target="build\stylecop.json" />
2324
<file src="README.md" target="docs\" />
2425
</files>

Neolution.CodeAnalysis.nuspec

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1313
<developmentDependency>true</developmentDependency>
1414
<dependencies>
15-
<dependency id="StyleCop.Analyzers" version="1.2.0-beta.435" />
16-
<dependency id="SonarAnalyzer.CSharp" version="8.52.0.60960" />
15+
<dependency id="StyleCop.Analyzers.Unstable" version="1.2.0.556" />
16+
<dependency id="SonarAnalyzer.CSharp" version="8.56.0.67649" />
1717
</dependencies>
1818
</metadata>
1919
<files>
2020
<file src="build\Neolution.CodeAnalysis.props" target="build\Neolution.CodeAnalysis.props" />
21-
<file src="build\Neolution.globalconfig" target="build\Neolution.globalconfig" />
21+
<file src="build\Neolution.CodeAnalysis.globalconfig" target="build\Neolution.CodeAnalysis.globalconfig" />
2222
<file src="build\stylecop.json" target="build\stylecop.json" />
2323
<file src="README.md" target="docs\" />
2424
</files>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Top level entry required to mark this as a global AnalyzerConfig file
2+
# NOTE: Do not create section headers for configuration entries
3+
is_global = true
4+
5+
# For conflicting rules, the higher level has higher priority
6+
global_level = 101
7+
8+
#############################################
9+
########## Rules specific to tests ##########
10+
#############################################
11+
12+
# CA1707: Identifiers should not contain underscores
13+
; We use underscores in test method names to make them easier to read.
14+
dotnet_diagnostic.CA1707.severity = none
15+
16+
# CA1031: Do not catch general exception types
17+
; Since we can raise any Exception we like In Tests we should also be able to catch any Exception we like.
18+
dotnet_diagnostic.CA1031.severity = none
19+
20+
# CA2000: Dispose objects before losing scope
21+
; Tests are never run continuously in a production environment. Resources are freed as soon as the Test run ends, so there is no need to worry about the pitfalls of not freeing resources.
22+
dotnet_diagnostic.CA2000.severity = none
23+
24+
# CA2007: Consider calling ConfigureAwait on the awaited task
25+
; This warning is intended for libraries, where the code may be executed in arbitrary environments and where code shouldn't make assumptions about the environment or how the caller of the method may be invoking or waiting on it
26+
dotnet_diagnostic.CA2007.severity = none
27+
28+
# S112: General exceptions should never be thrown
29+
; In Tests we should be able to raise any Exception we like.
30+
dotnet_diagnostic.S112.severity = none
31+
32+
# S131: "switch/Select" statements should contain a "default/Case Else" clauses
33+
; There is no need for defensive programming in Tests
34+
dotnet_diagnostic.S131.severity = none
35+
36+
# S126: "if ... else if" constructs should end with "else" clauses
37+
; There is no need for defensive programming in Tests
38+
dotnet_diagnostic.S126.severity = none
39+
40+
# S4581: "new Guid()" should not be used
41+
; When creating mocks/substitutes this can be irrelevant, so it should not break the build
42+
dotnet_diagnostic.S4581.severity = suggestion

build/Neolution.CodeAnalysis.TestsRuleset.props

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)Neolution.Tests.globalconfig" />
17+
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)Neolution.CodeAnalysis.globalconfig" Link=".globalconfig" />
18+
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)Neolution.CodeAnalysis.TestsRuleset.globalconfig" Link=".tests.globalconfig" />
1819
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
1920
</ItemGroup>
2021

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1-
# Top level entry required to mark this as a global AnalyzerConfig file
1+
# Top level entry required to mark this as a global AnalyzerConfig file
22
# NOTE: Do not create section headers for configuration entries
33
is_global = true
44

5+
# For conflicting rules, the higher level has higher priority
6+
global_level = 100
7+
58
# Literals should not be passed as localized parameters
69
; Localization is not needed in every project and for every message. This rule disallows string literals everywhere e.g. for log messages, content that does not need to be translated etc.
710
dotnet_diagnostic.S4055.severity = none
@@ -243,6 +246,10 @@ dotnet_diagnostic.S3257.severity = suggestion
243246
; This can be an annoying rule in cases where it does not really improve readability or even worsens it.
244247
dotnet_diagnostic.S3267.severity = suggestion
245248

249+
# CA2000: Dispose objects before losing scopes
250+
; Developers should be warned when they create disposable objects without disposing them
251+
dotnet_diagnostic.CA2000.severity = warning
252+
246253
# S107: Methods should not have too many parameters
247254
dotnet_diagnostic.S107.severity = warning
248255

build/Neolution.CodeAnalysis.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</PropertyGroup>
1515

1616
<ItemGroup>
17-
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)Neolution.globalconfig" />
17+
<GlobalAnalyzerConfigFiles Include="$(MSBuildThisFileDirectory)Neolution.CodeAnalysis.globalconfig" Link=".globalconfig" />
1818
<AdditionalFiles Include="$(MSBuildThisFileDirectory)stylecop.json" Link="stylecop.json" />
1919
</ItemGroup>
2020

0 commit comments

Comments
 (0)