Skip to content

JS-1686 Rule S1244 Floating point numbers should not be tested for equality#7119

Draft
sonar-nigel[bot] wants to merge 2 commits into
masterfrom
new-rule/JS-1686-S1244
Draft

JS-1686 Rule S1244 Floating point numbers should not be tested for equality#7119
sonar-nigel[bot] wants to merge 2 commits into
masterfrom
new-rule/JS-1686-S1244

Conversation

@sonar-nigel
Copy link
Copy Markdown
Contributor

@sonar-nigel sonar-nigel Bot commented May 28, 2026

Implements JavaScript/TypeScript rule S1244 to detect exact equality and inequality checks on floating-point-sensitive expressions.

  • Adds the S1244 rule metadata and rule entry point.
  • Detects direct and indirect exact comparisons involving float-sensitive expressions.
  • Covers exact assertion APIs that can hide the same comparison pattern.
  • Adds unit tests for the new detection behavior.
  • Preserves TypeScript narrowing for indirect comparison operands by storing logical operands in locals before applying comparison guards.

Sonar Vibe Bot added 2 commits May 28, 2026 13:03
Detect exact equality and inequality checks on floating-point-sensitive expressions, including indirect comparisons and exact assertion APIs.
Preserve BinaryExpression narrowing for indirect comparison operands by storing logical operands in locals before applying the comparison type guard. This fixes the TypeScript compile error while keeping the S1244 detection algorithm unchanged.
@sonar-nigel sonar-nigel Bot temporarily deployed to sca-checking May 28, 2026 13:05 Inactive
@sonarqubecloud
Copy link
Copy Markdown

Agentic Analysis: Early Results

Agentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action.

2 issue(s) found across 1 file(s):

Rule File Line Message
typescript:S3358 packages/analysis/src/jsts/rules/S1244/rule.ts 187 Extract this nested ternary operation into an independent statement.
typescript:S3514 packages/analysis/src/jsts/rules/S1244/rule.ts 219 Use destructuring syntax for these assignments from "node".

Analyzed by SonarQube Agentic Analysis in 3.1 s

@github-actions
Copy link
Copy Markdown
Contributor

Ruling Report

No changes to ruling expected issues in this PR

@sonarqube-next
Copy link
Copy Markdown

Quality Gate failed Quality Gate failed

Failed conditions
2 New issues

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

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.

0 participants