Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate S4158: Passing as argument removes constraint #7433

Merged
merged 6 commits into from
Jun 16, 2023

Conversation

Tim-Pohlmann
Copy link
Contributor

@Tim-Pohlmann Tim-Pohlmann commented Jun 14, 2023

Fixes #7300
Draft because it relies on #7418

Comment on lines -1 to -30
{
"issues": [
{
"id": "S4158",
"message": "Remove this call, the collection is known to be empty here.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Configuration\MappingExpressionBase.cs",
"region": {
"startLine": 174,
"startColumn": 21,
"endLine": 174,
"endColumn": 42
}
}
},
{
"id": "S4158",
"message": "Remove this call, the collection is known to be empty here.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\TypeMap.cs",
"region": {
"startLine": 44,
"startColumn": 17,
"endLine": 44,
"endColumn": 38
}
}
}
]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FPs

Comment on lines -1 to -30
{
"issues": [
{
"id": "S4158",
"message": "Remove this call, the collection is known to be empty here.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\Configuration\MappingExpressionBase.cs",
"region": {
"startLine": 174,
"startColumn": 21,
"endLine": 174,
"endColumn": 42
}
}
},
{
"id": "S4158",
"message": "Remove this call, the collection is known to be empty here.",
"location": {
"uri": "sources\Automapper\src\AutoMapper\TypeMap.cs",
"region": {
"startLine": 44,
"startColumn": 17,
"endLine": 44,
"endColumn": 38
}
}
}
]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FPs

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We'll need to look for arguments to inspect them

@Tim-Pohlmann Tim-Pohlmann marked this pull request as draft June 15, 2023 11:31
@Tim-Pohlmann Tim-Pohlmann changed the base branch from master to Tim/S4158_DictionarySet June 15, 2023 11:31
@Tim-Pohlmann Tim-Pohlmann force-pushed the Tim/S4158_DictionarySet branch 2 times, most recently from d219c8e to 7ec4f7a Compare June 15, 2023 12:33
Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small ProgramState redesign to make it work better

Copy link
Contributor

@pavel-mikula-sonarsource pavel-mikula-sonarsource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 196 to 197
validator.ValidateTag("AfterField", x => x.Should().BeNull());
validator.ValidateTag("AfterStaticField", x => x.Should().BeNull());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clean as you code: This method should be refactored to use TagValue instead. The two will end up as .TagValue("AfterField").Should().HaveNoConstraint(), effectively ignoring the null implementation detail (this UT doesn't care)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same on few methods below - only those you've modified

@@ -200,14 +200,14 @@ public void Test()
validator.TagStates("End").Should().SatisfyRespectively(
x =>
{
x[validator.Symbol("ObjectField")].HasConstraint<ObjectConstraint>().Should().BeFalse();
x[validator.Symbol("ObjectField")].Should().BeNull();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All assertions in this UT should use .Should().HaveNoConstraint() instead of null, and Should.HaveOnlyConstraints(.....) for the rest

Base automatically changed from Tim/S4158_DictionarySet to master June 16, 2023 13:02
@Tim-Pohlmann Tim-Pohlmann marked this pull request as ready for review June 16, 2023 13:16
@sonarcloud
Copy link

sonarcloud bot commented Jun 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@sonarcloud
Copy link

sonarcloud bot commented Jun 16, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@Tim-Pohlmann Tim-Pohlmann merged commit 6dceab4 into master Jun 16, 2023
@Tim-Pohlmann Tim-Pohlmann deleted the Tim/S4158_PassedAsArgument branch June 16, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate S4158 to the new Symbolic Execution engine
2 participants