-
Notifications
You must be signed in to change notification settings - Fork 229
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
Fix S3900 FP: Recognize VB extensions #7047
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly doubts on the behavior of the rule, by looking at the ITs.
The review took a while due to the fact that a lot of changes appearing in this PR actually belong to another PR (#7045), which is also in the review phase, and the related commit (Squash S3900-VB) had to be taken out from the diff, while reviewing.
I think it would have been easier for this PR to target the branch of #7045, rather than master
. This way there would have not been the need of squashing 7045 content into a single commit and asking for the review of the difference, since the full PR diff (and the Changes tab on GitHub) would have reflected the actual content of this PR.
Concerning ITs: it was difficult to only review the difference between the JSON files, as they appear in 7045, and the JSON as they appear here, so I went through all of them in this PR anyway. Most likely some comments will apply to 7045 instead.
...ommon/SymbolicExecution/Roslyn/RuleChecks/PublicMethodArgumentsShouldBeCheckedForNullBase.cs
Show resolved
Hide resolved
@@ -0,0 +1,264 @@ | |||
{ | |||
"issues": [ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit confused by how S3900 is working here.
This corresponds to the line:
sFormula.Replace("(", String.Empty).Length = sFormula.Replace(")", String.Empty).Length
Do you know why only the first sFormula
dereference is detected, and not the second, yet the third is (line 169)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The =
is a comparison operator. It learns NotNull from evaluating the left operand, and by the time it evaluates the right one, it already knows NotNull.
This seems fine to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the rule not reporting on the right side of the comparison, after having learnt NotNull
on the left side, is fine to me too. What still confuses me is line 169:
If sFormula.Replace("(", String.Empty).Length = sFormula.Replace(")", String.Empty).Length Then
'step 2: all code between brackets
For Each mReg In Regex.Matches(sFormula, "\((.+)\)")
rResult = EvaluateFormula(mReg.Groups(1).ToString())
sFormula = sFormula.Replace(mReg.ToString(), rResult.ToString("0.00")) ' Line 169
Next
Inside the If
, sFormula
has ObjectConstraint.NotNull
, and it seems to me that there is nothing that should make the engine forget about such constraint. Is it linked to the fact that the loop is executed twice, and sFormula
is assigned the result of sFormula.Replace
, making sFormula
unknown at the second iteration?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly.
.../its/expected/Ember-MM/Ember Media Manager-{9B57D3AB-AF12-4012-B945-284C2448DC81}-S3900.json
Outdated
Show resolved
Hide resolved
analyzers/its/expected/Ember-MM/EmberAPI-{208AA35E-C6AE-4D2D-A9DD-B6EFD19A4279}-S3900.json
Outdated
Show resolved
Hide resolved
analyzers/its/expected/Ember-MM/EmberAPI-{208AA35E-C6AE-4D2D-A9DD-B6EFD19A4279}-S3900.json
Outdated
Show resolved
Hide resolved
...ts/expected/Ember-MM/generic.EmberCore.NMT-{84B2143A-D04F-4262-923D-21AEDF86E2B7}-S3900.json
Outdated
Show resolved
Hide resolved
...d/Ember-MM/generic.EmberCore.Notifications-{2A08A524-88DA-432F-92E6-8DC63C5376DA}-S3900.json
Outdated
Show resolved
Hide resolved
...ts/expected/Ember-MM/scraper.EmberCore.XML-{E567C031-1F7B-4637-9B3A-806988DE50CF}-S3900.json
Show resolved
Hide resolved
...ts/expected/Ember-MM/scraper.EmberCore.XML-{E567C031-1F7B-4637-9B3A-806988DE50CF}-S3900.json
Outdated
Show resolved
Hide resolved
...rs/its/expected/Ember-MM/scraper.EmberCore-{EF6A550E-DD76-4F4D-8250-8598140F828B}-S3900.json
Outdated
Show resolved
Hide resolved
0b55e24
to
0b595fe
Compare
0b595fe
to
37e7dd6
Compare
Kudos, SonarCloud Quality Gate passed! |
Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thanks for the clarification, now the functionality is much more clear to me!
One doubt left: #7047 (comment)
Follow up of #6797
This is a draft, rebase will be needed.
Squash S3900-VB
commit doesn't need a review, it's in #7045