SONARPHP-1835 fix: Remove superfluous throws Exception declarations from test methods#1716
Open
sonarqube-agent[bot] wants to merge 1 commit into
Open
SONARPHP-1835 fix: Remove superfluous throws Exception declarations from test methods#1716sonarqube-agent[bot] wants to merge 1 commit into
sonarqube-agent[bot] wants to merge 1 commit into
Conversation
Fixed issues: - AZkoU_erIsbR56mqmhIb for java:S1130 rule - AZkoU_f1IsbR56mqmhIh for java:S1130 rule - AZkoU_EVIsbR56mqmhG6 for java:S1130 rule - AZkoU_EmIsbR56mqmhG7 for java:S1130 rule - AZkoU_F2IsbR56mqmhG_ for java:S1130 rule Generated by SonarQube Agent (task: 46878f59-b480-415f-b9ab-c27b3222c821)
Contributor
|
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.





Removed unnecessary 'throws Exception' declarations from 5 test methods that don't actually throw any checked exceptions. This resolves SonarQube code smells (S1130) and improves code clarity by ensuring method signatures accurately reflect the exceptions they can throw.
View Project in SonarCloud
Fixed Issues
java:S1130 - Remove the declaration of thrown exception 'java.lang.Exception', as it cannot be thrown from method's body. • MINOR • View issue
Location:
php:php-checks/src/test/java/org/sonar/php/checks/CollapsibleIfStatementCheckTest.java:25Why is this an issue?
Superfluous exceptions within
throwsclauses have negative effects on the readability and maintainability of the code. An exception in athrowsclause is superfluous if it is:What changed
Removes the superfluous 'throws Exception' declaration from the test() method signature, since no exception is actually thrown from the method's body. This addresses the code smell about declaring thrown exceptions that cannot be thrown from the method's body.
java:S1130 - Remove the declaration of thrown exception 'java.lang.Exception', as it cannot be thrown from method's body. • MINOR • View issue
Location:
php:php-checks/src/test/java/org/sonar/php/checks/TooManyLinesInFileCheckTest.java:32Why is this an issue?
Superfluous exceptions within
throwsclauses have negative effects on the readability and maintainability of the code. An exception in athrowsclause is superfluous if it is:What changed
Removes the superfluous 'throws Exception' declaration from the 'defaultValue()' method signature. The method body does not actually throw any checked exception of type 'java.lang.Exception', so declaring it in the throws clause is unnecessary and reduces code readability. By removing it, the method signature accurately reflects the exceptions that can actually be thrown.
java:S1130 - Remove the declaration of thrown exception 'java.lang.Exception', as it cannot be thrown from method's body. • MINOR • View issue
Location:
php:php-checks/src/test/java/org/sonar/php/checks/regex/EmptyAlternativeCheckTest.java:25Why is this an issue?
Superfluous exceptions within
throwsclauses have negative effects on the readability and maintainability of the code. An exception in athrowsclause is superfluous if it is:What changed
Removes the superfluous 'throws Exception' declaration from the test() method signature, since no exception is actually thrown from the method's body. This directly addresses the code smell about declaring thrown exceptions that cannot be thrown from the method's body.
java:S1130 - Remove the declaration of thrown exception 'java.lang.Exception', as it cannot be thrown from method's body. • MINOR • View issue
Location:
php:php-checks/src/test/java/org/sonar/php/checks/regex/ImpossibleBoundariesCheckTest.java:25Why is this an issue?
Superfluous exceptions within
throwsclauses have negative effects on the readability and maintainability of the code. An exception in athrowsclause is superfluous if it is:What changed
Removes the superfluous 'throws Exception' declaration from the test method 'test()' in ImpossibleBoundariesCheckTest.java. The method body does not actually throw any checked exception, so declaring 'throws Exception' is unnecessary and reduces code readability. By removing this declaration, the method signature becomes cleaner and compliant with the rule that exceptions listed in a throws clause should actually be throwable from the method's body.
java:S1130 - Remove the declaration of thrown exception 'java.lang.Exception', as it cannot be thrown from method's body. • MINOR • View issue
Location:
php:php-checks/src/test/java/org/sonar/php/checks/regex/SingleCharCharacterClassCheckTest.java:25Why is this an issue?
Superfluous exceptions within
throwsclauses have negative effects on the readability and maintainability of the code. An exception in athrowsclause is superfluous if it is:What changed
Removes the superfluous 'throws Exception' declaration from the test method 'test()' in SingleCharCharacterClassCheckTest.java. The method body does not actually throw any checked exception, so the 'throws Exception' clause was unnecessary and flagged as a code smell. By removing it, the method signature accurately reflects that no checked exceptions are thrown.
SonarQube Remediation Agent uses AI. Check for mistakes.