Skip to content

fix: refactor handleRegularCharacter to eliminate invariant return - #25

Merged
ggulpari merged 3 commits into
mainfrom
claude/fix-issue-01QypNZfYqiqBj5n9zsh4yne
Nov 16, 2025
Merged

fix: refactor handleRegularCharacter to eliminate invariant return#25
ggulpari merged 3 commits into
mainfrom
claude/fix-issue-01QypNZfYqiqBj5n9zsh4yne

Conversation

@Slashmsu

Copy link
Copy Markdown
Collaborator

Resolves SonarQube code smell S3516 by removing redundant if-else branches that both returned the same value. The function now advances the position unconditionally and only conditionally updates line/column tracking for newlines before returning the character once at the end.

This maintains identical behavior while improving code maintainability.

🎉 Pull Request

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality
    to not work as expected)
  • 📚 Documentation update
  • 🔧 Configuration/build changes
  • ✅ Test improvements
  • ♻️ Code refactoring (no functional changes)

Related Issue

Fixes #(issue number)

Changes Made

Testing

  • All existing tests pass (npm test)
  • Added new tests for the changes
  • Tested manually with examples
  • Linting passes (npm run lint)
  • Type checking passes (npm run type-check)

Checklist

  • My code follows the project's code style guidelines
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Context


📋 License Information

SomonScript is open source software licensed under the MIT License.

By submitting this pull request, you agree that your contributions will be
licensed under the MIT License.

For contribution guidelines, please review:


Thank you for contributing to SomonScript! 🚀

@github-actions

Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

Resolves SonarQube code smell S3516 by removing redundant if-else
branches that both returned the same value. The function now advances
the position unconditionally and only conditionally updates line/column
tracking for newlines before returning the character once at the end.

This maintains identical behavior while improving code maintainability.
@github-actions

Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

@Slashmsu Slashmsu self-assigned this Nov 16, 2025
@Slashmsu
Slashmsu requested a review from ggulpari November 16, 2025 15:09
Refactors lineColMatch array access to use optional chaining (?.[])
instead of logical AND (&&) operators, making the code more concise
and easier to read. This addresses SonarQube code quality suggestions
while maintaining identical functionality.

Changes:
- Line 233: lineColMatch ? lineColMatch[1] → lineColMatch?.[1]
- Line 234: lineColMatch && lineColMatch[2] → lineColMatch?.[2]
ggulpari
ggulpari previously approved these changes Nov 16, 2025
@Slashmsu
Slashmsu force-pushed the claude/fix-issue-01QypNZfYqiqBj5n9zsh4yne branch from aed4ac8 to d33d617 Compare November 16, 2025 15:09
@github-actions

Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

Remove duplicate coverage badges as CodeCov badge already provides
test coverage information. This eliminates redundancy and keeps the
badge section cleaner.

Files updated:
- README.md (English)
- README.ru.md (Russian)
- README.tj.md (Tajik)
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

✅ Tests completed on Node.js 20.x: success

@ggulpari
ggulpari self-requested a review November 16, 2025 15:23
@ggulpari
ggulpari merged commit 1bf2d3a into main Nov 16, 2025
11 of 13 checks passed
@ggulpari
ggulpari deleted the claude/fix-issue-01QypNZfYqiqBj5n9zsh4yne branch November 16, 2025 15:24
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.

2 participants