fix: resolve 5 SonarQube issues - merge nested ifs and extract constants#32
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
fix: resolve 5 SonarQube issues - merge nested ifs and extract constants#32sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZZjJguBOPkSvG45yHz- for python:S1066 rule - AZZjJgtKOPkSvG45yHz1 for python:S1192 rule - AZZjJgtKOPkSvG45yHz3 for python:S1192 rule - AZZjJgtKOPkSvG45yHz0 for python:S1192 rule - AZZjJgtKOPkSvG45yHz2 for python:S1192 rule Generated by SonarQube Agent (task: f9be9ffc-963c-4704-94c5-4b8ec30403ad)
Author
|
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Consolidates nested if statements in construct_mapping_global.py to reduce unnecessary nesting and improves code maintainability in construct_mappings.py by extracting duplicated string literals into four constants (ICON_PLUS, MAP_STYLE, INDENT, ARROW_PLUS). This eliminates code smells flagged by SonarQube and makes the codebase more readable and easier to maintain.
View Project in SonarCloud
Fixed Issues
python:S1066 - Merge this if statement with the enclosing one. • MAJOR • View issue
Location:
PlantUML/construct_mapping_global.py:76Why is this an issue?
Nested code - blocks of code inside blocks of code - is eventually necessary, but increases complexity. This is why keeping the code as flat as possible, by avoiding unnecessary nesting, is considered a good practice.
What changed
This hunk merges two nested
ifstatements —if row[1] != row[2]:andif row[3] is not None and row[4] is not None:— into a singleifstatement usingand:if row[1] != row[2] and row[3] is not None and row[4] is not None:. This reduces unnecessary nesting, making the code flatter and more readable, which directly addresses the code smell about collapsible nestedifstatements at line 76 inconstruct_mapping_global.py.python:S1192 - Define a constant instead of duplicating this literal '<&plus> ' 6 times. • CRITICAL • View issue
Location:
PlantUML/construct_mappings.py:308Why is this an issue?
Duplicated string literals make the process of refactoring complex and error-prone, as any change would need to be propagated on all occurrences.
What changed
Defines four constants (ICON_PLUS, MAP_STYLE, INDENT, ARROW_PLUS) that replace duplicated string literals throughout the code. ICON_PLUS replaces the 6 duplications of '<&plus> ', MAP_STYLE replaces the 9 duplications of ' #back:WhiteSmoke;header:LightGray {', INDENT replaces the 16 duplications of '\n ', and ARROW_PLUS replaces the 3 duplications of ' => <&plus> '. This hunk provides the constant definitions that all subsequent hunks reference.
python:S1192 - Define a constant instead of duplicating this literal ' #back:WhiteSmoke;header:LightGray {' 9 times. • CRITICAL • View issue
Location:
PlantUML/construct_mappings.py:313Why is this an issue?
Duplicated string literals make the process of refactoring complex and error-prone, as any change would need to be propagated on all occurrences.
What changed
Defines four constants (ICON_PLUS, MAP_STYLE, INDENT, ARROW_PLUS) that replace duplicated string literals throughout the code. ICON_PLUS replaces the 6 duplications of '<&plus> ', MAP_STYLE replaces the 9 duplications of ' #back:WhiteSmoke;header:LightGray {', INDENT replaces the 16 duplications of '\n ', and ARROW_PLUS replaces the 3 duplications of ' => <&plus> '. This hunk provides the constant definitions that all subsequent hunks reference.
python:S1192 - Define a constant instead of duplicating this literal '\n ' 16 times. • CRITICAL • View issue
Location:
PlantUML/construct_mappings.py:329Why is this an issue?
Duplicated string literals make the process of refactoring complex and error-prone, as any change would need to be propagated on all occurrences.
What changed
Defines four constants (ICON_PLUS, MAP_STYLE, INDENT, ARROW_PLUS) that replace duplicated string literals throughout the code. ICON_PLUS replaces the 6 duplications of '<&plus> ', MAP_STYLE replaces the 9 duplications of ' #back:WhiteSmoke;header:LightGray {', INDENT replaces the 16 duplications of '\n ', and ARROW_PLUS replaces the 3 duplications of ' => <&plus> '. This hunk provides the constant definitions that all subsequent hunks reference.
python:S1192 - Define a constant instead of duplicating this literal ' => <&plus> ' 3 times. • CRITICAL • View issue
Location:
PlantUML/construct_mappings.py:376Why is this an issue?
Duplicated string literals make the process of refactoring complex and error-prone, as any change would need to be propagated on all occurrences.
What changed
Defines four constants (ICON_PLUS, MAP_STYLE, INDENT, ARROW_PLUS) that replace duplicated string literals throughout the code. ICON_PLUS replaces the 6 duplications of '<&plus> ', MAP_STYLE replaces the 9 duplications of ' #back:WhiteSmoke;header:LightGray {', INDENT replaces the 16 duplications of '\n ', and ARROW_PLUS replaces the 3 duplications of ' => <&plus> '. This hunk provides the constant definitions that all subsequent hunks reference.
SonarQube Remediation Agent uses AI. Check for mistakes.