Skip to content

fix(musicutils): correct typo in convertFactor - 0.675 should be 0.625 (5/8)#7460

Open
Harshit-Mishra2212 wants to merge 2 commits into
sugarlabs:masterfrom
Harshit-Mishra2212:fix/convertFactor-five-eighths-typo
Open

fix(musicutils): correct typo in convertFactor - 0.675 should be 0.625 (5/8)#7460
Harshit-Mishra2212 wants to merge 2 commits into
sugarlabs:masterfrom
Harshit-Mishra2212:fix/convertFactor-five-eighths-typo

Conversation

@Harshit-Mishra2212

Copy link
Copy Markdown
Contributor

Description

convertFactor in musicutils.js maps beat duration values to their LilyPond string representations. The case for 5/8 contained a typo:

case 0.675: // 5/8    ← wrong, 0.675 is not a valid musical fraction
    return "2 8";

The correct value for 5/8 is 0.625, not 0.675. As a result:

  • convertFactor(0.625) fell through to default and returned null
  • In notation.js, a null return silently drops the tempo or pickup marking in LilyPond export for any project using a 5/8 beat value - the notation is exported without the correct tempo/pickup
  • 0.675 is unreachable in practice since no standard musical computation produces it

The existing test also contained the same typo and was therefore passing against the wrong value.

Related Issue

No related issue — bug identified through code analysis.

PR Category

  • Bug Fix

Changes Made

  • js/utils/musicutils.js: change case 0.675 to case 0.625
  • js/utils/__tests__/musicutils.test.js: update test input from 0.675 to 0.625, and add convertFactor(0.675) to the null test to confirm it is not a valid factor

Testing Performed

  • Ran npm test -- musicutils - all tests pass
  • Ran full test suite npm test - no regressions introduced
  • Note: one pre-existing failure in js/widgets/__tests__/aidebugger.test.js (unrelated to this PR)

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes.
  • I have followed the project's coding style guidelines.
  • I have run npm run lint and npx prettier --check . with no errors.
  • I have enabled "Allow edits from maintainers"

@github-actions github-actions Bot added bug fix Fixes a bug or incorrect behavior size/XS Extra small: < 10 lines changed area/javascript Changes to JS source files area/tests Changes to test files labels Jun 2, 2026
@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🧪 Jest Test Results

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Coverage: Statements: 48.23% | Branches: 39.77% | Functions: 52.95% | Lines: 48.62%
Master Coverage: Statements: 48.23% | Branches: 39.77% | Functions: 52.95% | Lines: 48.62%

Note: These failures may be introduced by this PR or may already exist in the master branch.
Tip: Update your branch with the latest master and rerun tests.
If the same failures are present on master, they are likely not introduced by this PR.

Failed Tests:

aidebugger.test.js

@github-actions

github-actions Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

🧪 Jest Test Results

❌ Some Jest tests failed. Please check the logs and fix the issues before merging.

Coverage: Statements: 48.23% | Branches: 39.77% | Functions: 52.95% | Lines: 48.62%
Master Coverage: Statements: 48.23% | Branches: 39.77% | Functions: 52.95% | Lines: 48.62%

Note: These failures may be introduced by this PR or may already exist in the master branch.
Tip: Update your branch with the latest master and rerun tests.
If the same failures are present on master, they are likely not introduced by this PR.

Failed Tests:

aidebugger.test.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/javascript Changes to JS source files area/tests Changes to test files bug fix Fixes a bug or incorrect behavior size/XS Extra small: < 10 lines changed

Projects

Development

Successfully merging this pull request may close these issues.

1 participant