-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Custom CheckStyle Rule #9: Thrown exception use ClientLogger #4566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…heck for public class for external Dependency check
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml
Outdated
Show resolved
Hide resolved
...thubs/azure-eventhubs/src/main/java/com/azure/messaging/eventhubs/EventHubClientBuilder.java
Show resolved
Hide resolved
joshfree
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved, pending changes
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
sdk/core/azure-core-management/src/main/java/com/azure/core/management/PagedList.java
Outdated
Show resolved
Hide resolved
sdk/core/azure-core-management/src/main/java/com/azure/core/management/PagedList.java
Outdated
Show resolved
Hide resolved
...quality-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrownClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
|
The rule requirement changes. Thank you for your past and next code reviews. Includes the fixes for Storages as well now. |
| } else { | ||
| return; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this no longer necessary as you are instead configuring it via suppressions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. you are right.
...lity-reports/src/main/java/com/azure/tools/checkstyle/checks/ThrowFromClientLoggerCheck.java
Outdated
Show resolved
Hide resolved
| protected Object handleResumeOperation(HttpRequest httpRequest, OperationDescription operationDescription, SwaggerMethodParser methodParser, Type returnType, Context context) | ||
| throws Exception { | ||
| throw new Exception("The resume operation is not available in the base RestProxy class."); | ||
| throw logger.logExceptionAsError(new RuntimeException("The resume operation is not available in the base RestProxy class.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need double confirm that change Exception to RuntimeException. If can't, will suppress this error
alzimmermsft
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes look good to me, we'll want to file issues to each library to update whether the exceptions should be logged as warnings or errors, this is important to help reduce non-important logging and reducing how many logs customs have.
PR includes:
(1) the implementation for Rule 9: Thrown exception use ClientLogger
To throw an exception, Must throw it through a 'logger.logExceptionAsError', rather than by directly calling 'throw exception'.
Skip check if throw exception from
(2) code fixes based on the new rule: ThrowFromClientLoggerCheck.java
(3) a minor fixes for NoImplInPublicAPI.java checker:
(4) fixes for ServiceClientBuilder checker for Storage service.