PhpStorm is adding errors into my code whenever I let the automatic code inspection run. I like using it when committing, because it fixes my indentation.
Here's my code with testing values before the commit:
/**
* Calculates and selects the average score of a single user.
* This will also have to calculate the score in different criteria.
*/
DECLARE @Max_Grade INTEGER
SET @Max_Grade = 6
DECLARE @User_ID INTEGER
SET @User_ID = 16
DECLARE @Basic_Weight INTEGER
SET @Basic_Weight = 10
DECLARE @Daily_Weight FLOAT
SET @Daily_Weight = 0.5
-- Create temporary utility table.
-- This table will contain each appraisal and its maximum score vs. total score of all
-- questions.
DECLARE @Score_Table TABLE
(
[Appraisal_ID] INTEGER,
[Total_Score] FLOAT,
[Maximum_Score] FLOAT
)
INSERT INTO @Score_Table (
[Appraisal_ID],
[Total_Score],
[Maximum_Score]
) (
SELECT
[Appraisal].[Appraisal_ID] AS [Appraisal_ID]
, SUM(
[Question].[Grade] *
(
@Basic_Weight +
@Daily_Weight * DATEDIFF(DAY, [Plan].[From_Time], [Plan].[To_Time])
)
)
AS [Total_Score]
, SUM(
@Max_Grade *
(
@Basic_Weight +
@Daily_Weight * DATEDIFF(DAY, [Plan].[From_Time], [Plan].[To_Time])
)
)
AS [Maximum_Score]
FROM
[Question], [Appraisal], [Plan]
WHERE
[Question].[Grade] IS NOT NULL AND
[Question].[Grade] != 0 AND
[Appraisal].[Appraisal_ID] = [Question].[Appraisal_ID] AND
[Plan].[Plan_ID] = [Appraisal].[Plan_ID] AND
[Appraisal].[User_ID_Candidate] = @User_ID AND
[Appraisal].[Disabled] IS NULL AND
-- DONE Criterium: Only count those appraisals that are completed
[Appraisal].[Choice_Candidate] IS NOT NULL AND
[Appraisal].[Choice_Candidate] <> 0 AND
[Appraisal].[Choice_Owner] IS NOT NULL AND
[Appraisal].[Choice_Owner] <> 0
GROUP BY [Appraisal].[Appraisal_ID]
)
SELECT
NULL,
-- Calculate the end result by dividing the final results and multiplaying by maximum grade
(
SUM([Total_Score]) /
SUM([Maximum_Score])
) * @Max_Grade
FROM @Score_Table
UNION
-- Select all grades as floats
SELECT
[Appraisal_ID],
-- Divide the actual weighted grade by the maximum weighted grade and multiply it by the maximum grade to get the
-- average score of each
-- appraisal.
-- Total Score:
[Total_Score] /
-- Divided by Maximum Score:
[Maximum_Score] * @Max_Grade
AS [Average_Grade]
FROM @Score_Table
Committing and letting the automatic code scan run will change several lines, putting three variables all over the code into [brackets] - all occurrences except for their declarations.
/**
* Calculates and selects the average score of a single user.
* This will also have to calculate the score in different criteria.
*/
DECLARE @Max_Grade INTEGER
SET @Max_Grade = 6
DECLARE @User_ID INTEGER
SET @User_ID = 16
DECLARE @Basic_Weight INTEGER
SET @Basic_Weight = 10
DECLARE @Daily_Weight FLOAT
SET @Daily_Weight = 0.5
-- Create temporary utility table.
-- This table will contain each appraisal and its maximum score vs. total score of all
-- questions.
DECLARE [@Score_Table] TABLE
(
[Appraisal_ID] INTEGER,
[Total_Score] FLOAT,
[Maximum_Score] FLOAT
)
INSERT INTO [@Score_Table] (
[Appraisal_ID],
[Total_Score],
[Maximum_Score]
) (
SELECT
[Appraisal].[Appraisal_ID] AS [Appraisal_ID]
, SUM(
[Question].[Grade] *
(
[@Basic_Weight] +
[@Daily_Weight] * DATEDIFF(DAY, [Plan].[From_Time], [Plan].[To_Time])
)
)
AS [Total_Score]
, SUM(
[@Max_Grade] *
(
[@Basic_Weight] +
[@Daily_Weight] * DATEDIFF(DAY, [Plan].[From_Time], [Plan].[To_Time])
)
)
AS [Maximum_Score]
FROM
[Question], [Appraisal], [Plan]
WHERE
[Question].[Grade] IS NOT NULL AND
[Question].[Grade] != 0 AND
[Appraisal].[Appraisal_ID] = [Question].[Appraisal_ID] AND
[Plan].[Plan_ID] = [Appraisal].[Plan_ID] AND
[Appraisal].[User_ID_Candidate] = @User_ID AND
[Appraisal].[Disabled] IS NULL AND
-- DONE Criterium: Only count those appraisals that are completed
[Appraisal].[Choice_Candidate] IS NOT NULL AND
[Appraisal].[Choice_Candidate] <> 0 AND
[Appraisal].[Choice_Owner] IS NOT NULL AND
[Appraisal].[Choice_Owner] <> 0
GROUP BY [Appraisal].[Appraisal_ID]
)
SELECT
NULL,
-- Calculate the end result by dividing the final results and multiplaying by maximum grade
(
SUM([Total_Score]) /
SUM([Maximum_Score])
) * @Max_Grade
FROM @Score_Table
UNION
-- Select all grades as floats
SELECT
[Appraisal_ID],
-- Divide the actual weighted grade by the maximum weighted grade and multiply it by the maximum grade to get the
-- average score of each
-- appraisal.
-- Total Score:
[Total_Score] /
-- Divided by Maximum Score:
[Maximum_Score] * @Max_Grade
AS [Average_Grade]
FROM @Score_Table
All four variables except for @User_ID
are automatically quoted. Unfortunately, the script breaks in lines 21, 77 and 95 because of the inconsistent quoting of variables. I don't think you could even declare them if you quote them.
The feature is disabled in both the IDE config and the project default config:
I've tried code inspection with and without this option.
Version/About:
Could anyone point me into the right direction? I could exclude the file from the automatic code inspection, but before I start excluding several files because of this issue, I'd like to hear alternative solutions.
Solution:
As @LazyOne said, the Code Style must be edited. There's an option to change Identifier Quotation. Mine was on.