10. Quality Measurement - khalillabban/Snorting-Code GitHub Wiki

Metric Sprint 1 Sprint 2 Sprint 3 Sprit 4 Sprint 5 Sprint 6
Size (LOC) 0 2 530 2 945 6 472 7 126 12 464
Duplication (%) 0 0 0 0.33 1.7 0
Cyclomatic Complexity 0 94 161 587 915 1621
Cognitive Complexity 0 62 96 326 487 898
Technical Debt (Min) 0 32 120 0 0 0
Security Issues 0 0 0 0 0 0
image image image

SonarQube vulnerability issues

SonarQube Vulnerability Issues – Sprint 3

Date: February 19, 2026

During Sprint 3, SonarCloud reports 8 maintainability issues on the main branch. There are no security vulnerabilities and no reliability issues, which confirms that the codebase remains stable and secure. The detected issues are primarily related to code readability, consistency, and maintainability improvements, rather than functional defects.

This low issue count reflects our practice of addressing SonarQube warnings during Pull Request reviews before merging to main.


Types of Issues Detected

The 8 issues fall into the following categories:

1. Nested Ternary Operators (2 Issues - Medium Severity)

  • Location: CampusMapScreen.tsx, BuildingInfoPopup.tsx
  • Issue: Nested ternary expressions reduce readability and increase cognitive load.
  • Sonar rule: Extract nested ternary into independent statements.

Impact: These do not break functionality but reduce clarity and maintainability.

Plan to Address:

  • Refactor nested ternaries into clear if/else blocks or intermediate variables.
  • Improves readability and aligns with clean code practices.

2. TODO Comment Not Resolved (1 Issue - Info)

  • Location: BuildingInfoPopup.tsx
  • Issue: A TODO comment indicates incomplete work.
  • Sonar rule: Track uses of TODO tags.

Impact: Indicates unfinished enhancement (bottom-sheet interaction handling).

Plan to Address:

  • Either implement the bottom-sheet drag handle interaction.
  • Or remove/comment-resolve the TODO if intentionally deferred to a later sprint.

3. Array Index Used as React Key (1 Issue - Medium)

  • Location: CampusMap.tsx
  • Issue: Using array index as key in JSX lists.
  • Sonar rule: JSX list components should not use array indexes as keys.

Impact: Can cause rendering inconsistencies if list order changes.

Plan to Address:

  • Replace index with a stable unique identifier (e.g., item string or ID).
  • Ensures predictable React reconciliation behavior.

4. Props Not Marked as Read-Only (2 Issues - Low)

  • Location: CampusMap.tsx
  • Issue: Component props are not explicitly marked readonly.

Impact: Minor maintainability concern - props should be immutable.

Plan to Address:

  • Update interface definitions:

    interface Props {
      readonly coordinate: ...
    }
  • Reinforces immutability conventions.


5. Unnecessary Decimal Fractions (2 Issues - Low)

  • Location: campuses.ts
  • Issue: Numeric literals include unnecessary trailing zeros (e.g., 45.4950).

Impact: Formatting inconsistency; no runtime effect.

Plan to Address:

  • Normalize numeric literals:

    45.4950 β†’ 45.495
    
  • Improves code cleanliness and consistency.


Overall Assessment - Sprint 3

  • Total Issues: 8
  • Security Issues: 0
  • Reliability Issues: 0
  • All Issues Type: Maintainability / Code Smell
  • Highest Severity: Medium
  • Estimated Technical Debt: ~27 minutes

All detected issues are non-critical and non-functional, meaning they do not impact runtime correctness or user safety. They primarily improve readability, React best practices, and stylistic consistency.


Action Plan for Next Sprint

In Sprint 4, we will:

  1. Refactor nested ternary operators.
  2. Replace array index keys with stable identifiers.
  3. Mark all React props as readonly.
  4. Normalize numeric formatting.
  5. Resolve or remove TODO comments.
  6. Integrate SonarCloud rule enforcement into PR checklist to prevent recurrence.

This structured approach ensures that maintainability remains high while continuing feature development.

SonarQube Vulnerability Issues – Sprint 4

Date: March 2026

1. Nested Ternary Operators (6 Issues - Medium Severity)

  • Location: CampusMapScreen.tsx, CampusMap.tsx, ShuttleSchedulePanel.tsx
  • Issue: Nested ternary expressions reduce readability and increase cognitive load.
  • Sonar rule: Extract nested ternary operation into an independent statement.

Impact: These do not break functionality but reduce clarity and maintainability.


2. Components as Read-Only (4 Issues - Low Severity)

  • Location: DirectionStepsPanel.tsx, ShuttleSchedulePanel.tsx, ShuttleUnavailableBanner.tsx
  • Issue: Component props are not explicitly marked as read-only.
  • Sonar rule: Mark the props of the component as read-only.

Impact: Minor maintainability concern β€” props should be immutable.


3. No use of array index in keys (3 Issues - Medium Severity)

  • Location: CampusMap.tsx, DirectionStepsPanel.tsx, ShuttleBus.tsx
  • Issue: The map() function in list rendering uses the array index as the key prop for rendered elements.
  • Sonar rule: Do not use Array index in keys.

Impact: Using an index as a key can lead to unpredictable component state and rendering bugs. If the list is filtered or reordered, React will identify elements by their index rather than their identity.


4. Remove useless assignment variable (4 Issues - Medium Severity)

  • Location: CampusMap.tsx
  • Issue: Variables are being calculated and assigned but are never referenced in the returned JSX or subsequent logic (for example routeCoords, shuttleRouteCoords, campusLabel, startOrEnd).
  • Sonar rule: Remove this useless assignment to variable.

Impact: Dead code increases cognitive load for maintainers, making the logic harder to read and understand. It can also create confusion about whether a feature was partially implemented or if a variable was accidentally forgotten.


5. Exception Handling Improvement (1 Issue - Low Severity)

  • Location: CampusMap.tsx
  • Issue: An exception is caught but not properly handled.
  • Sonar rule: Handle this exception or do not catch it at all.

Impact: Improper exception handling can hide errors and make debugging more difficult. Ensuring that caught exceptions are handled correctly improves reliability and debugging clarity.


Overall Assessment – Sprint 4

During Sprint 4, SonarQube detected a set of new maintainability issues introduced within the last 5–6 days. These issues are primarily related to code readability, React best practices, and minor code cleanliness improvements rather than functional problems.

No security issues or reliability issues were detected, which indicates that the application remains stable and secure. The identified warnings mostly involve nested ternary expressions, unused variables, and React-specific conventions such as avoiding array indexes as keys and enforcing immutability of component props.

These findings highlight opportunities to improve the maintainability of the codebase while keeping the system behavior unchanged. Since the issues are mostly stylistic or structural, they can be resolved with relatively small refactoring changes.


Action Plan for Next Sprint

In the next sprint, the team plans to address these SonarQube findings through targeted refactoring tasks.

First, nested ternary expressions will be replaced with clearer conditional logic using if/else statements or intermediate variables. This will improve code readability and reduce cognitive complexity when maintaining the components.

Second, list rendering across the application will be updated so that React elements use stable identifiers instead of array indexes as keys. This will prevent potential rendering inconsistencies if lists are reordered or filtered in the future.

Third, unused variables and unnecessary assignments such as routeCoords, shuttleRouteCoords, campusLabel, and startOrEnd will be removed. Cleaning up this dead code will make the logic easier to read and reduce confusion for developers maintaining the project.

Fourth, component prop definitions will be updated to mark props as readonly where appropriate. This reinforces immutability practices in React and helps prevent accidental mutation of input data.

Finally, exception handling will be reviewed to ensure that caught errors are either properly handled or allowed to propagate when appropriate, improving debugging clarity and code reliability.

To prevent similar issues from accumulating, the team will continue integrating SonarQube analysis into the pull request review process, allowing maintainability issues to be identified and addressed early during development.


SonarQube Vulnerability Issues – Sprint 5

Date: March 2026

During Sprint 5, SonarCloud reports 13 maintainability issues on the main branch. There are no security vulnerabilities and no reliability issues, confirming that the system remains stable and secure.

All detected issues are related to code quality, readability, and best practices, particularly around React conventions, TypeScript usage, and reducing cognitive complexity.


Types of Issues Detected

The 13 issues fall into the following categories:


1. High Cognitive Complexity (1 Issue - High Severity)

  • Location: CampusMapScreen.tsx
  • Issue: Function exceeds allowed cognitive complexity (16 vs 15).
  • Sonar rule: Refactor function to reduce Cognitive Complexity.

Impact: Makes the function harder to understand, maintain, and extend. Increases risk of bugs when modifying logic.

Plan to Address:

  • Break the function into smaller helper functions.
  • Extract logic (e.g., routing, filtering, state handling) into separate hooks or utilities.
  • Improve readability and modularity.

2. Useless Variable Assignment (1 Issue - Medium Severity)

  • Location: IndoorMapScreen.tsx
  • Issue: searchQuery is assigned but not used.
  • Sonar rule: Remove this useless assignment to variable.

Impact: Creates confusion and unnecessary cognitive load for developers.

Plan to Address:

  • Remove unused variable or integrate it properly into logic if intended.

3. Optional Chaining Improvements (1 Issue - Medium Severity)

  • Location: IndoorMapScreen.tsx
  • Issue: Conditional checks can be simplified using optional chaining.
  • Sonar rule: Prefer optional chaining expression.

Impact: Reduces readability and increases verbosity of code.

Plan to Address:

  • Replace patterns like:

    obj && obj.prop

    with:

    obj?.prop

4. Unnecessary Escape Characters (2 Issues - Medium Severity)

  • Location: IndoorMapScreen.tsx
  • Issue: Redundant escape characters (\) in strings.
  • Sonar rule: Remove unnecessary escape characters.

Impact: No functional impact, but reduces code clarity and cleanliness.

Plan to Address:

  • Remove unnecessary escape characters in template strings.

5. Props Not Marked as Read-Only (4 Issues - Low Severity)

  • Location: IndoorRouteOverlay.tsx, IndoorDirectionsPanel.tsx, SegmentRow component

  • Issue: Component props are not marked as readonly.

  • Sonar rule: React props should be read-only.

Impact: Minor maintainability issue β€” props should be immutable.

Plan to Address:

  • Update interfaces:

    interface Props {
      readonly route: ...
    }

6. Array Index Usage and Access Improvements (2 Issues - Medium/Low Severity)

  • Location: IndoorDirectionsPanel.tsx, IndoorRouteOverlay.tsx

  • Issues:

    • Using array index as React key
    • Using [length - 1] instead of .at()
  • Sonar rules:

    • Do not use Array index in keys
    • Prefer .at() over index access

Impact:

  • Index keys can cause rendering bugs
  • Index-based access reduces readability

Plan to Address:

  • Replace:

    key={index}

    with a stable identifier

  • Replace:

    arr[arr.length - 1]

    with:

    arr.at(-1)

7. Negated Condition Readability (1 Issue - Low Severity)

  • Location: IndoorDirectionsPanel.tsx
  • Issue: Use of negated condition in JSX.
  • Sonar rule: Avoid negated conditions when possible.

Impact: Reduces readability of UI logic.

Plan to Address:

  • Refactor:

    !condition ? A : B

    into clearer positive condition.


8. Nested Template Literals (1 Issue - Medium Severity)

  • Location: NavigationBar.tsx
  • Issue: Nested template strings reduce readability.
  • Sonar rule: Do not use nested template literals.

Impact: Makes string construction harder to understand.

Plan to Address:

  • Extract intermediate variables:

    const roomName = result.room?.roomName ?? "";
    return `${result.room.label}${roomName}`;

9. Nullish Coalescing Improvement (1 Issue - Low Severity)

  • Location: NavigationBar.tsx
  • Issue: Use ?? instead of assignment-based fallback.
  • Sonar rule: Prefer nullish coalescing operator.

Impact: Improves clarity and modern JS consistency.

Plan to Address:

  • Replace:

    if (!value) value = fallback;

    with:

    value = value ?? fallback;

Overall Assessment – Sprint 5

During Sprint 5, SonarQube identified 13 maintainability issues, with 1 high severity, several medium issues, and the rest low severity.

No security or reliability issues were detected, indicating that the application remains functionally stable and safe.

Compared to previous sprints, the issues are more focused on:

  • Code readability
  • Modern JavaScript/TypeScript practices
  • React best practices
  • Reducing cognitive complexity

The presence of one high-severity cognitive complexity issue highlights an opportunity to further improve code modularity and separation of concerns.


Action Plan for Next Sprint

In Sprint 6, we will:

  1. Refactor high-complexity functions into smaller modular units.
  2. Remove unused variables and dead code.
  3. Apply optional chaining and nullish coalescing consistently.
  4. Eliminate unnecessary escape characters and nested template literals.
  5. Replace array index keys with stable identifiers.
  6. Update all React props to be readonly.
  7. Improve conditional readability by avoiding negated expressions.
  8. Continue enforcing SonarQube rules during PR reviews.

This ensures continued improvement of code maintainability, readability, and long-term scalability while preserving system stability.


SonarQube Vulnerability Issues – Sprint 6

Date: April 2026

During Sprint 6, SonarCloud reports 5 maintainability issues on the main branch. There are no security vulnerabilities and no reliability issues, confirming that the system remains stable and secure.

The detected issues are related to cognitive complexity, code readability, and TypeScript type safety, primarily focusing on improving maintainability rather than fixing functional defects.


Types of Issues Detected


1. High Cognitive Complexity (1 Issue - High Severity)

  • Location: CampusMapScreen.tsx (Line ~550)
  • Issue: Function exceeds allowed cognitive complexity (23 vs 15 allowed)
  • Sonar rule: Refactor function to reduce Cognitive Complexity (typescript:S3776)

Impact: This significantly increases the difficulty of understanding, maintaining, and modifying the function. High cognitive complexity introduces risk when extending or debugging the logic.

Plan to Address:

  • Break the function into smaller helper functions.

  • Extract logic into:

    • Routing logic
    • State handling
    • Data transformation
  • Move reusable logic into hooks or utility files.

  • Reduce nested conditions and simplify control flow.


2. Nested Ternary Operators (2 Issues - Medium Severity)

  • Location: app/index.tsx (Line ~112)
  • Issue: Nested ternary expressions used inside JSX (Color mode display logic)
  • Sonar rule: Extract this nested ternary operation into an independent statement

Impact: Nested ternaries significantly reduce readability and increase cognitive load, especially inside JSX. This makes UI logic harder to understand and maintain.

Plan to Address:

let modeLabel;

if (mode === "classic") modeLabel = "Classic";
else if (mode === "redGreenSafe") modeLabel = "Red-Green Safe";
else if (mode === "blueYellowSafe") modeLabel = "Blue-Yellow Safe";
else modeLabel = "High Contrast";
<Text>Color mode: {modeLabel}</Text>
  • Improves readability and aligns with clean code practices.

3. Redundant Union Type (1 Issue - Low Severity)

  • Location: CampusMap.tsx (Line ~148)
  • Issue: Union type ("walking" | "shuttle" | "bicycling" | "driving" | "transit") is overridden by string
  • Sonar rule: Type constituents of unions should not be redundant (typescript:S6571)

Impact: Redundant union types reduce type safety and clarity. Including string overrides the benefits of explicitly defined literal types, making the union ineffective.

Plan to Address:

mode: RouteStrategy["mode"];
  • Remove | string from the type definition to enforce strict typing.

4. Type Safety / Redundant Type Handling (1 Issue - Low Severity)

  • Location: CampusMap.tsx
  • Issue: Improper normalization and casting of mode (as RouteStrategy["mode"])
  • Sonar rule: Avoid unnecessary type assertions / enforce safer typing

Impact: Overuse of type assertions can hide potential bugs and weakens TypeScript’s guarantees.

Plan to Address:

  • Validate mode before casting instead of forcing type:
const normalizedMode = (mode?.toLowerCase() ?? "walking") as RouteStrategy["mode"];

β†’ replace with controlled validation or mapping function.


Overall Assessment – Sprint 6

During Sprint 6, SonarQube detected 5 maintainability issues, consisting of:

  • 1 High Severity issue
  • 2 Medium Severity issues
  • 2 Low Severity issues
  • 0 Security Issues
  • 0 Reliability Issues

Compared to Sprint 5 (13 issues), this represents a significant improvement in code quality. The remaining issues are non-functional and focus on improving readability, maintainability, and type safety.


Final Action Plan

As Sprint 6 is the final sprint, the team will address all remaining issues as part of final cleanup:

  1. Refactor the high-complexity function in CampusMapScreen.tsx.
  2. Replace nested ternary expressions with clearer conditional logic.
  3. Remove redundant union types and enforce strict typing.
  4. Reduce reliance on unsafe type assertions.
  5. Ensure all SonarQube issues are resolved before final submission.

This ensures the project is delivered with a clean, maintainable, and production-ready codebase.


⚠️ **GitHub.com Fallback** ⚠️