Code Analysis feedback - EI003 false positive and too restrive PE006
BuckleyRE
Posts: 3 New member
in SQL Prompt
I got some feedback for the code analysis tool on one of our bigger code bases which for a first use worked great.
1. false positive for rule "EI003" - Non-scalar subquery in place of a scalar
Repro. The analyse trips of the union in the following example
DELETE FROM
dbo.Person
WHERE
PersonID NOT IN (
SELECT
par.Person_ID
FROM
dbo.PersonAccountRole par
WHERE
par.Person_ID IS NOT NULL
UNION
SELECT
Buyer_Decision_Maker
FROM
dbo.TransactionNL
WHERE
Buyer_Decision_Maker IS NOT NULL
)
2. Misplaced warning (IMO) for rule PE006 - TABLE HINT is used
Repro. A readuncommitted hint (nolock) or any other isolation level hint is not in scope of this otherwise good advice.
SELECT * FROM Lookup.Person WITH (READUNCOMMITTED)
A nolock is common use for reports or diagnostic queries.
The description of this rule is
"
It is not a good idea to use any of the rich variety of table hints.
The SQL Server query optimizer usually selects the best index for a join, so these be used only as a last resort by experienced
developers and database administrators.
"
Agreed that, as in the the description, when a MERGE/LOOP/HASH join hint is used a warning is appropriate.
3. Is it possible to disable a rule with a comment so that the rule applies in general but not on some lines?
Kind Regards, Tom
1. false positive for rule "EI003" - Non-scalar subquery in place of a scalar
Repro. The analyse trips of the union in the following example
DELETE FROM
dbo.Person
WHERE
PersonID NOT IN (
SELECT
par.Person_ID
FROM
dbo.PersonAccountRole par
WHERE
par.Person_ID IS NOT NULL
UNION
SELECT
Buyer_Decision_Maker
FROM
dbo.TransactionNL
WHERE
Buyer_Decision_Maker IS NOT NULL
)
2. Misplaced warning (IMO) for rule PE006 - TABLE HINT is used
Repro. A readuncommitted hint (nolock) or any other isolation level hint is not in scope of this otherwise good advice.
SELECT * FROM Lookup.Person WITH (READUNCOMMITTED)
A nolock is common use for reports or diagnostic queries.
The description of this rule is
"
It is not a good idea to use any of the rich variety of table hints.
The SQL Server query optimizer usually selects the best index for a join, so these be used only as a last resort by experienced
developers and database administrators.
"
Agreed that, as in the the description, when a MERGE/LOOP/HASH join hint is used a warning is appropriate.
3. Is it possible to disable a rule with a comment so that the rule applies in general but not on some lines?
Kind Regards, Tom
Tagged:
Comments
Thanks for getting in touch. We have logged your first two requests as bugs under references SP-6829 and SP-6830.
Regarding your question "Is it possible to disable a rule with a comment so that the rule applies in general but not on some lines?", we have an open suggestion on our UserVoice portal to add this functionality.
https://redgate.uservoice.com/forums/94413-sql-prompt/suggestions/32531393-code-analysis-disable-rule-for-specific-cases
Would it be possible to vote/comment on it there so that we can collect feedback together?
Best,
Michael
Technical Lead, SQL Monitor
Is it possible to follow up on the bugs?
Thanks for your post.
The development team is now aware of this and will be assessing it going forward.
We don't have a definitive time frame set for this to be implemented.
Instead, please keep an eye on new versions and the release notes for SQL Prompt.
I hope this information is helpful to you.
Kind regards
Redgate Software