Skip to content

Fix SonarCloud high-priority code quality issues#114

Open
Vipin-Sharma wants to merge 1 commit intomasterfrom
fix/sonarcloud-remaining-issues
Open

Fix SonarCloud high-priority code quality issues#114
Vipin-Sharma wants to merge 1 commit intomasterfrom
fix/sonarcloud-remaining-issues

Conversation

@Vipin-Sharma
Copy link
Copy Markdown
Owner

Summary

Fixed multiple high-priority SonarCloud code quality issues focusing on string literal duplication and unnecessary exception declarations.

Changes Made

1. SQLServerDataTypeEnum - String Literal Duplication Fix (Critical Priority)

Problem: String literals were duplicated multiple times across enum values:

  • "String" - 8 occurrences
  • "Byte[]" - 3 occurrences
  • "Timestamp" - 4 occurrences
  • "BigDecimal" - 4 occurrences

Solution: Created inner JdbcType utility class with constants:

private static final class JdbcType {
    static final String STRING = "String";
    static final String BYTE_ARRAY = "Byte[]";
    static final String TIMESTAMP = "Timestamp";
    static final String BIG_DECIMAL = "BigDecimal";
    // ... other types
}

Now enum values reference these constants instead of duplicating strings:

CHAR("CHAR", String.class, JdbcType.STRING),
BINARY("BINARY", byte[].class, JdbcType.BYTE_ARRAY),

Benefits:

  • Single source of truth for JDBC type names
  • Easier maintenance - change once, applies everywhere
  • Eliminates magic strings throughout the enum
  • Maintains full backward compatibility

2. Generator Tests - Removed Unnecessary Exception Declarations (Minor Priority)

Cleaned up test methods that declared throws Exception but never actually throw checked exceptions:

  • SelectMicroserviceGeneratorTest:

    • testGenerateSelectMicroservice_SqlException_PropagatesException()
    • testGenerateSelectMicroservice_MetadataExtractionFailure_PropagatesException()
  • UpdateMicroserviceGeneratorTest:

    • testGenerateUpdateMicroservice_DatabaseConnectionFailure_PropagatesException()

These methods only throw SQLException or RuntimeException (unchecked), so the throws Exception declaration was misleading and unnecessary.

Test Results

✅ All 981 tests passing
✅ No functional changes - pure code quality improvements
✅ Full backward compatibility maintained

Impact on SonarCloud

This PR resolves:

  • 4 Critical code smells (string literal duplication)
  • 3 Minor code smells (unnecessary exception declarations)

🤖 Generated with Claude Code

…eptions

Fixed high-priority SonarCloud issues:

1. SQLServerDataTypeEnum - String literal duplication fix:
   - Created inner JdbcType class with constants for repeated JDBC type strings
   - Eliminates duplication of "String" (8x), "Byte[]" (3x), "Timestamp" (4x), "BigDecimal" (4x)
   - Maintains backward compatibility - all tests pass

2. Generator test cleanup - Removed unused exception declarations:
   - SelectMicroserviceGeneratorTest: Removed 2 unnecessary 'throws Exception'
   - UpdateMicroserviceGeneratorTest: Removed 1 unnecessary 'throws Exception'
   - These methods don't throw checked exceptions, declarations were misleading

All 981 tests passing successfully.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Oct 2, 2025

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