Skip to content

False positives FA0704/FA0705 for CHARINDEX, SUBSTRING, EOMONTH #4

@AndyPLsql

Description

@AndyPLsql

Hi!
I found false positives in argument validation for valid T-SQL cases, but I can’t open a PR from my fork (fork PRs are disabled), so sharing this as an issue.

Problem

The linter reports FA0704/FA0705 for valid SQL:

SELECT EOMONTH(@dt, 1);
SELECT CHARINDEX('CD', 'ABCDEF', -3);
SELECT SUBSTRING('ABCDEF', 0, 3);
SELECT SUBSTRING('ABCDEF', -2, 3);

Also, this case should be reported as out-of-range argument:

SELECT EOMONTH('9999-12-01', 1);

Expected

  • EOMONTH supports 1..2 arguments.
  • CHARINDEX and SUBSTRING should accept non-positive start per SQL Server behavior.
  • EOMONTH overflow with month_to_add should be handled as out-of-range.

Reference implementation

I already implemented a fix in my fork: https://github.com/IVNSTN/TeamTools.Linter.TSQL/compare/main...AndyPLsql:TeamTools.Linter.TSQL:feature/fix_invalid_argument?expand=1

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions