Skip to content

Commit

Permalink
Fixes on Check on checkstyle (Azure#5003)
Browse files Browse the repository at this point in the history
* remove java code isImple check but move to suppression and add only check for public class for external Dependency check

* fixes

* Update eng/code-quality-reports/src/main/resources/checkstyle/checkstyle-suppressions.xml

suggest changes on comments

Co-Authored-By: Connie Yau <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Aug 15, 2019
1 parent d043adc commit 3f0befe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Licensed under the MIT License.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.tools.checkstyle.checks;

Expand All @@ -19,8 +19,8 @@
*/
public class OnlyFinalFieldsForImmutableClassCheck extends AbstractCheck {
private static final String IMMUTABLE_NOTATION = "Immutable";
private static final String ERROR_MSG = "The variable field ''%s'' should be final." +
"Classes annotated with @Immutable are supposed to be immutable.";
private static final String ERROR_MSG = "The variable field ''%s'' should be final."
+ "Classes annotated with @Immutable are supposed to be immutable.";

private boolean hasImmutableAnnotation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void visitToken(DetailAST token) {
// method name has prefix 'build' but not 'build*Client' or 'build*AsyncClient'
if (!methodName.endsWith("Client")) {
log(token, String.format(
"@ServiceClientBuilder class should not have a method name, ''%s'' starting with ''build'' but not ending with ''Client''." , methodName));
"@ServiceClientBuilder class should not have a method name, ''%s'' starting with ''build'' but not ending with ''Client''.", methodName));
}
break;
default:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.tools.checkstyle.checks;

import com.puppycrawl.tools.checkstyle.api.DetailAST;
Expand Down Expand Up @@ -39,7 +42,7 @@ protected static boolean hasIllegalCombination(DetailAST modifiers) {
Optional<DetailAST> illegalCombination = TokenUtil.findFirstTokenByPredicate(modifiers, (node) -> {
final int type = node.getType();
return INVALID_FINAL_COMBINATION.contains(node.getType()) || (TokenTypes.ANNOTATION == type
&& INVALID_FINAL_ANNOTATIONS.contains(node.findFirstToken(TokenTypes.IDENT).getText()));
&& INVALID_FINAL_ANNOTATIONS.contains(node.findFirstToken(TokenTypes.IDENT).getText()));
});

return illegalCombination.isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@
<suppress checks="com.azure.tools.checkstyle.checks.ExternalDependencyExposedCheck" files=".*[/\\]samples[/\\].*\.java"/>
<suppress checks="com.azure.tools.checkstyle.checks.HttpPipelinePolicyCheck" files=".*[/\\]samples[/\\].*\.java"/>

<!-- Don't apply custom Checkstyle rules to files under checkstyle package. -->
<suppress checks="com\.azure\.tools\.checkstyle\.checks\..+" files=".*[/\\]tools[/\\]checkstyle[/\\].*"/>

<!-- JavaPackage suppression -->
<suppress checks="JavadocPackage" files=".*[/\\]samples[/\\].*\.java"/>

Expand Down

0 comments on commit 3f0befe

Please sign in to comment.