Skip to content

Declare Framingham stroke points as int arrays - #1718

Open
namespaceMarcello wants to merge 1 commit into
synthetichealth:masterfrom
namespaceMarcello:fix/framingham-stroke-points-int
Open

namespaceMarcello wants to merge 1 commit into
synthetichealth:masterfrom
namespaceMarcello:fix/framingham-stroke-points-int

Conversation

@namespaceMarcello

Copy link
Copy Markdown

Problem

In Framingham.stroke10Year(), the diabetes, coronary heart disease and atrial fibrillation points are stored in double[] arrays (diabetes_stroke, chd_stroke_points, atrial_fibrillation_stroke_points) and added to int strokePoints with +=, which silently narrows a double to an int. CodeQL flags the three lines as java/implicit-cast-in-compound-assignment (high).

Everything else added to strokePoints in the method is already an int: the points for smoking and left ventricular hypertrophy, and the indexes returned by getIndexForValueInRangelist.

Solution

Declare the three arrays as int[]. Their values ({2, 3}, {4, 2}, {4, 6}) are whole numbers, so the points, the stroke risk and the generated patients are unchanged.

Tests

No behavior changes, so there is no new test.

  • The full ./gradlew test suite passes locally (JDK 21), and checkstyle reports no warnings on the changed file.
  • CodeQL on a fork of current master reports these three alerts and nothing else in the Java code.

This PR was written by Claude Code (AI assistant) on behalf of @namespaceMarcello, who directs this work.

🤖 Generated with Claude Code

The diabetes, coronary heart disease and atrial fibrillation stroke
points were declared as double[] although they are whole numbers and
are added to the int strokePoints, so each += narrowed a double to an
int. CodeQL reports this as java/implicit-cast-in-compound-assignment.

The values are unchanged, so the computed stroke risk and the
generated patients stay the same.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant