Skip to content

Commit

Permalink
Issue sevntu-checkstyle#734: Fixed remaining checkstyle violations fr…
Browse files Browse the repository at this point in the history
…om travis build
  • Loading branch information
mbert committed May 15, 2019
1 parent e8a599b commit bf9a578
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,10 @@ public final void visitToken(final DetailAST ast) {
packageExcluded = isPackageExcluded(FullIdent.createFullIdent(nameAST));
}
else if (!packageExcluded) {
handleDefinition(ast);
final AbstractJsr305Check handler = handleDefinition(ast);
if (handler != null) {
handler.check();
}
}
}

Expand Down Expand Up @@ -468,21 +471,22 @@ protected void runcheck() {
checkContainsAll(MSG_PARAM_NONNULL_AND_NULLABLE,
NullnessAnnotation.NONNULL, NullnessAnnotation.NULLABLE);

final NullnessAnnotation firstAncestorAnnotation = getParentMethodOrClassAnnotation(
NullnessAnnotation.PARAMETERS_ARE_NONNULL_BY_DEFAULT,
NullnessAnnotation.PARAMETERS_ARE_NULLABLE_BY_DEFAULT);
final boolean parametersAreNonnullByDefault =
firstAncestorAnnotation == NullnessAnnotation.PARAMETERS_ARE_NONNULL_BY_DEFAULT;
final boolean parametersAreNullableByDefault = firstAncestorAnnotation
== NullnessAnnotation.PARAMETERS_ARE_NULLABLE_BY_DEFAULT;
final boolean isMethodOverridden = isMethodOverridden();

if (isPrimitiveType()) {
checkContainsAny(MSG_PRIMITIVES_WITH_NULLNESS_ANNOTATION,
NullnessAnnotation.CHECK_FOR_NULL, NullnessAnnotation.NONNULL,
NullnessAnnotation.NULLABLE);
}
else {
final NullnessAnnotation firstAncestorAnnotation =
getParentMethodOrClassAnnotation(
NullnessAnnotation.PARAMETERS_ARE_NONNULL_BY_DEFAULT,
NullnessAnnotation.PARAMETERS_ARE_NULLABLE_BY_DEFAULT);
final boolean isMethodOverridden = isMethodOverridden();
final boolean parametersAreNonnullByDefault = firstAncestorAnnotation
== NullnessAnnotation.PARAMETERS_ARE_NONNULL_BY_DEFAULT;
final boolean parametersAreNullableByDefault = firstAncestorAnnotation
== NullnessAnnotation.PARAMETERS_ARE_NULLABLE_BY_DEFAULT;

if (isMethodOverridden && !allowOverridingParameter) {
checkContainsAny(MSG_OVERRIDDEN_WITH_INCREASED_CONSTRAINT,
NullnessAnnotation.NONNULL);
Expand Down Expand Up @@ -523,7 +527,7 @@ protected AbstractMethodJsr305Check(final DetailAST ast) {
* Run the actual check.
*/
@Override
protected final void runcheck() {
protected void runcheck() {
checkContainsAll(MSG_CONTRADICTING_CLASS_LEVEL_ANNOTATIONS,
NullnessAnnotation.PARAMETERS_ARE_NONNULL_BY_DEFAULT,
NullnessAnnotation.PARAMETERS_ARE_NULLABLE_BY_DEFAULT);
Expand Down Expand Up @@ -657,13 +661,21 @@ public abstract class AbstractJsr305Check {
* the ast
*/
protected AbstractJsr305Check(final DetailAST ast) {
errorFound = false;
theAst = ast;
errorFound = false;
if (ast == null) {
theAnnotations = Collections.emptySet();
}
else {
theAnnotations = findAnnotation();
}
}

/**
* Run the actual check.
*/
public final void check() {
if (theAst != null) {
runcheck();
}
}
Expand Down
Loading

0 comments on commit bf9a578

Please sign in to comment.