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 |
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.
The 8 issues fall into the following categories:
- 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/elseblocks or intermediate variables. - Improves readability and aligns with clean code practices.
- Location:
BuildingInfoPopup.tsx - Issue: A
TODOcomment 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.
- 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
indexwith a stable unique identifier (e.g., item string or ID). - Ensures predictable React reconciliation behavior.
- 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.
- 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.
- 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.
In Sprint 4, we will:
- Refactor nested ternary operators.
- Replace array index keys with stable identifiers.
- Mark all React props as
readonly. - Normalize numeric formatting.
- Resolve or remove TODO comments.
- Integrate SonarCloud rule enforcement into PR checklist to prevent recurrence.
This structured approach ensures that maintainability remains high while continuing feature development.
Date: March 2026
- 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.
- 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.
- 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.
- 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.
- 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.
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.
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.
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.
The 13 issues fall into the following categories:
- 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.
- Location:
IndoorMapScreen.tsx - Issue:
searchQueryis 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.
- 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
- 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.
-
Location:
IndoorRouteOverlay.tsx,IndoorDirectionsPanel.tsx,SegmentRowcomponent -
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: ... }
-
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)
- 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.
- 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}`;
- 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;
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.
In Sprint 6, we will:
- Refactor high-complexity functions into smaller modular units.
- Remove unused variables and dead code.
- Apply optional chaining and nullish coalescing consistently.
- Eliminate unnecessary escape characters and nested template literals.
- Replace array index keys with stable identifiers.
- Update all React props to be
readonly. - Improve conditional readability by avoiding negated expressions.
- Continue enforcing SonarQube rules during PR reviews.
This ensures continued improvement of code maintainability, readability, and long-term scalability while preserving system stability.
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.
- 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.
- Location:
app/index.tsx(Line ~112) - Issue: Nested ternary expressions used inside JSX (
Color modedisplay 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.
- Location:
CampusMap.tsx(Line ~148) - Issue: Union type (
"walking" | "shuttle" | "bicycling" | "driving" | "transit") is overridden bystring - 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
| stringfrom the type definition to enforce strict typing.
- 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
modebefore casting instead of forcing type:
const normalizedMode = (mode?.toLowerCase() ?? "walking") as RouteStrategy["mode"];β replace with controlled validation or mapping function.
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.
As Sprint 6 is the final sprint, the team will address all remaining issues as part of final cleanup:
- Refactor the high-complexity function in
CampusMapScreen.tsx. - Replace nested ternary expressions with clearer conditional logic.
- Remove redundant union types and enforce strict typing.
- Reduce reliance on unsafe type assertions.
- Ensure all SonarQube issues are resolved before final submission.
This ensures the project is delivered with a clean, maintainable, and production-ready codebase.