Skip to content

Commit a8b3939

Browse files
committed
add Qodana static code analysis
1 parent a8dacda commit a8b3939

File tree

8 files changed

+202
-6
lines changed

8 files changed

+202
-6
lines changed

.editorconfig

-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ csharp_space_between_method_call_parameter_list_parentheses = false
152152
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
153153
csharp_space_between_method_declaration_name_and_open_parenthesis = false
154154
csharp_space_between_method_declaration_parameter_list_parentheses = false
155-
csharp_space_between_parentheses = false
156155
csharp_space_between_square_brackets = false
157156

158157
# Alignment
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: Qodana
2+
on:
3+
workflow_dispatch:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
qodana:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
checks: write
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
ref: ${{ github.event.pull_request.head.sha }}
20+
fetch-depth: 0
21+
- name: 'Qodana Scan'
22+
uses: jetbrains/[email protected]
23+
env:
24+
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ TestResults
6161
ClientBin
6262
stylecop.*
6363
~$*
64-
*~
6564
*.dbmdl
6665
site/
6766
Generated_Code #added for RIA/Silverlight projects
@@ -87,7 +86,6 @@ _NCrunch_GitVersion
8786
GitVersion.sln.ide/
8887
.vs/
8988
Packages/
90-
site/
9189
/TestResult.xml
9290

9391
################

build/CI.sln

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
3939
..\.github\workflows\winget.yml = ..\.github\workflows\winget.yml
4040
..\.github\workflows\mkdocs.yml = ..\.github\workflows\mkdocs.yml
4141
..\.github\dependabot.yml = ..\.github\dependabot.yml
42+
..\.github\workflows\qodana_code_quality.yml = ..\.github\workflows\qodana_code_quality.yml
4243
EndProjectSection
4344
EndProject
4445
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "actions", "actions", "{A9B92261-AB9C-47D6-A8A7-616A5A62B063}"

qodana.yaml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#-------------------------------------------------------------------------------#
2+
# Qodana analysis is configured by qodana.yaml file #
3+
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
4+
#-------------------------------------------------------------------------------#
5+
version: "1.0"
6+
#Specify IDE code to run analysis without container (Applied in CI/CD pipeline)
7+
ide: QDNET
8+
#Specify inspection profile for code analysis
9+
profile:
10+
name: qodana.starter
11+
include:
12+
- name: ConvertIfStatementToReturnStatement
13+
- name: ConvertIfStatementToConditionalTernaryExpression
14+
- name: AutoPropertyCanBeMadeGetOnly.Global
15+
- name: CanReplaceCastWithLambdaReturnType
16+
- name: ChangeFieldTypeToSystemThreadingLock
17+
- name: ConvertIfStatementToSwitchStatement
18+
- name: ConvertToConstant.Local
19+
- name: DuplicatedSequentialIfBodies
20+
- name: InlineTemporaryVariable
21+
- name: InvertIf
22+
- name: UseVerbatimString
23+
- name: LoopCanBeConvertedToQuery
24+
- name: MemberCanBePrivate.Global
25+
- name: MemberCanBeProtected.Global
26+
- name: MergeIntoPattern
27+
- name: UnusedMethodReturnValue.Global
28+
- name: EditorConfigNoMatchingFiles
29+
- name: ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
30+
- name: PreferConcreteValueOverDefault
31+
- name: PropertyCanBeMadeInitOnly.Global
32+
- name: MoveLocalFunctionAfterJumpStatement
33+
- name: RedundantExplicitParamsArrayCreation
34+
- name: RedundantOverload.Global
35+
- name: RedundantStringInterpolation
36+
- name: RedundantVerbatimStringPrefix
37+
- name: ReplaceSubstringWithRangeIndexer
38+
- name: RCS1001
39+
- name: RCS1003
40+
- name: RCS1123
41+
- name: SYSLIB1045
42+
- name: CA1826
43+
- name: RCS1256
44+
- name: RCS1118
45+
- name: RCS1077
46+
- name: RCS1205
47+
- name: RCS1214
48+
- name: RCS1249
49+
- name: RCS1192
50+
- name: SYSLIB1054
51+
- name: CA1512
52+
- name: CA1866
53+
- name: CA1859
54+
- name: RCS1246
55+
- name: CA1829
56+
- name: RCS1266
57+
- name: RCS1267
58+
- name: RCS1227
59+
- name: SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault
60+
- name: SwitchStatementHandlesSomeKnownEnumValuesWithDefault
61+
- name: RedundantAlwaysMatchSubpattern
62+
- name: UnusedType.Global
63+
- name: UnusedMemberInSuper.Global
64+
- name: UnusedMember.Local
65+
- name: EditorConfigKeyCorrectness
66+
- name: UseCollectionCountProperty
67+
- name: UseDiscardAssignment
68+
- name: ArrangeNamespaceBody
69+
- name: SuggestDiscardDeclarationVarStyle
70+
- name: ArrangeTrailingCommaInMultilineLists
71+
- name: ArrangeObjectCreationWhenTypeNotEvident
72+
- name: UseRawString
73+
- name: VirtualMemberNeverOverridden.Global
74+
75+
#Enable inspections
76+
#include:
77+
# - name: <SomeEnabledInspectionId>
78+
#Disable inspections
79+
#exclude:
80+
# - name: <SomeDisabledInspectionId>
81+
# paths:
82+
# - <path/where/not/run/inspection>
83+
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
84+
#bootstrap: sh ./prepare-qodana.sh
85+
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
86+
#plugins:
87+
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

src/GitVersion.Configuration/ConfigurationSerializer.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ private sealed class JsonPropertyNameInspector(ITypeInspector innerTypeDescripto
3030
public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object? container) =>
3131
innerTypeDescriptor.GetProperties(type, container)
3232
.Where(p => p.GetCustomAttribute<JsonIgnoreAttribute>() == null)
33-
.Select(p =>
33+
.Select(IPropertyDescriptor (p) =>
3434
{
3535
var descriptor = new PropertyDescriptor(p);
3636
var member = p.GetCustomAttribute<JsonPropertyNameAttribute>();
@@ -39,7 +39,7 @@ public override IEnumerable<IPropertyDescriptor> GetProperties(Type type, object
3939
descriptor.Name = member.Name;
4040
}
4141

42-
return (IPropertyDescriptor)descriptor;
42+
return descriptor;
4343
})
4444
.OrderBy(p => p.Order);
4545
}

src/GitVersion.Configuration/GitVersionConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public string? NextVersion
120120

121121
[JsonIgnore]
122122
IReadOnlyDictionary<string, IBranchConfiguration> IGitVersionConfiguration.Branches
123-
=> Branches.ToDictionary(element => element.Key, element => (IBranchConfiguration)element.Value);
123+
=> Branches.ToDictionary(element => element.Key, IBranchConfiguration (element) => element.Value);
124124

125125
[JsonPropertyName("branches")]
126126
[JsonPropertyDescription("The header for all the individual branch configuration.")]

src/qodana.yaml

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#-------------------------------------------------------------------------------#
2+
# Qodana analysis is configured by qodana.yaml file #
3+
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
4+
#-------------------------------------------------------------------------------#
5+
version: "1.0"
6+
#Specify IDE code to run analysis without container (Applied in CI/CD pipeline)
7+
ide: QDNET
8+
#Specify inspection profile for code analysis
9+
profile:
10+
name: qodana.starter
11+
include:
12+
- name: ConvertIfStatementToReturnStatement
13+
- name: ConvertIfStatementToConditionalTernaryExpression
14+
- name: AutoPropertyCanBeMadeGetOnly.Global
15+
- name: CanReplaceCastWithLambdaReturnType
16+
- name: ChangeFieldTypeToSystemThreadingLock
17+
- name: ConvertIfStatementToSwitchStatement
18+
- name: ConvertToConstant.Local
19+
- name: DuplicatedSequentialIfBodies
20+
- name: InlineTemporaryVariable
21+
- name: InvertIf
22+
- name: UseVerbatimString
23+
- name: LoopCanBeConvertedToQuery
24+
- name: MemberCanBePrivate.Global
25+
- name: MemberCanBeProtected.Global
26+
- name: MergeIntoPattern
27+
- name: UnusedMethodReturnValue.Global
28+
- name: EditorConfigNoMatchingFiles
29+
- name: ForeachCanBePartlyConvertedToQueryUsingAnotherGetEnumerator
30+
- name: PreferConcreteValueOverDefault
31+
- name: PropertyCanBeMadeInitOnly.Global
32+
- name: MoveLocalFunctionAfterJumpStatement
33+
- name: RedundantExplicitParamsArrayCreation
34+
- name: RedundantOverload.Global
35+
- name: RedundantStringInterpolation
36+
- name: RedundantVerbatimStringPrefix
37+
- name: ReplaceSubstringWithRangeIndexer
38+
- name: RCS1001
39+
- name: RCS1003
40+
- name: RCS1123
41+
- name: SYSLIB1045
42+
- name: CA1826
43+
- name: RCS1256
44+
- name: RCS1118
45+
- name: RCS1077
46+
- name: RCS1205
47+
- name: RCS1214
48+
- name: RCS1249
49+
- name: RCS1192
50+
- name: SYSLIB1054
51+
- name: CA1512
52+
- name: CA1866
53+
- name: CA1859
54+
- name: RCS1246
55+
- name: CA1829
56+
- name: RCS1266
57+
- name: RCS1267
58+
- name: RCS1227
59+
- name: SwitchExpressionHandlesSomeKnownEnumValuesWithExceptionInDefault
60+
- name: SwitchStatementHandlesSomeKnownEnumValuesWithDefault
61+
- name: RedundantAlwaysMatchSubpattern
62+
- name: UnusedType.Global
63+
- name: UnusedMemberInSuper.Global
64+
- name: UnusedMember.Local
65+
- name: EditorConfigKeyCorrectness
66+
- name: UseCollectionCountProperty
67+
- name: UseDiscardAssignment
68+
- name: ArrangeNamespaceBody
69+
- name: SuggestDiscardDeclarationVarStyle
70+
- name: ArrangeTrailingCommaInMultilineLists
71+
- name: ArrangeObjectCreationWhenTypeNotEvident
72+
- name: UseRawString
73+
- name: VirtualMemberNeverOverridden.Global
74+
75+
#Enable inspections
76+
#include:
77+
# - name: <SomeEnabledInspectionId>
78+
#Disable inspections
79+
#exclude:
80+
# - name: <SomeDisabledInspectionId>
81+
# paths:
82+
# - <path/where/not/run/inspection>
83+
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
84+
#bootstrap: sh ./prepare-qodana.sh
85+
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
86+
#plugins:
87+
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)

0 commit comments

Comments
 (0)