SONARPHP-1838 fix: remove superfluous 'throws Exception' declarations from test methods#1717
Merged
felix-pauck-sonarsource merged 1 commit intoJun 1, 2026
Conversation
Fixed issues: - AZkoU_FNIsbR56mqmhG9 for java:S1130 rule - AZkoU_fcIsbR56mqmhIe for java:S1130 rule - AZkoU_fOIsbR56mqmhId for java:S1130 rule - AZkoU_fqIsbR56mqmhIf for java:S1130 rule - AZkoU_FkIsbR56mqmhG- for java:S1130 rule Generated by SonarQube Agent (task: 0a7dd872-5152-4ebb-a7d5-39a6e7f962e7)
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 across the php-checks module that were flagged by SonarQube rule S1130. These declarations were misleading since the methods do not actually throw any checked exceptions, so removing them improves code clarity and reduces false signals about exception handling.
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/GotoUseCheckTest.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 in GotoUseCheckTest.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 throws clauses should actually be thrown by the method's execution path.
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/RedefineConstantCheckTest.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 RedefineConstantCheckTest.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.
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/TooManyLinesInFunctionCheckTest.java:29Why 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 in TooManyLinesInFunctionCheckTest.java. The method body does not actually throw any checked exception of type java.lang.Exception, so the throws clause was unnecessary and flagged as a code smell. By removing it, the method signature accurately reflects that no checked exceptions are 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/EmptyGroupCheckTest.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 EmptyGroupCheckTest.java. The method body does not actually throw any checked exception, so declaring 'throws Exception' is unnecessary and reduces code readability. This directly addresses the code smell about removing declarations of 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/GroupReplacementCheckTest.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 GroupReplacementCheckTest.java. The method body does not actually throw any checked exception, so the 'throws Exception' clause was unnecessary and reduced code readability. By removing it, the method signature is cleaner and no longer declares an exception that cannot be thrown from the method's body.
SonarQube Remediation Agent uses AI. Check for mistakes.