Mark fields as final. #1555

Fixes `FieldMayBeFinal` inspection violations.

Description:
>Reports any fields which may safely be made final. A static field may be final if it is initialized in its declaration or in one static class initializer, but not both. A non-static field may be final if it is initialized in its declaration or in one non-static class initializer or in all constructors.
This commit is contained in:
Michal Kordas 2015-08-14 22:30:11 +02:00 committed by Roman Ivanov
parent 901d777e3d
commit 257983bcbf
2 changed files with 8 additions and 2 deletions

View File

@ -28,7 +28,7 @@ import com.puppycrawl.tools.checkstyle.api.FileContents;
*/
class CommentSuppressor implements MatchSuppressor {
/** File contents to check for comments. */
private FileContents currentContents;
private final FileContents currentContents;
/**
* Constructor for this suppressor.

View File

@ -312,7 +312,7 @@ public class SuppressionCommentFilter
private final Pattern tagCheckRegexp;
/** The parsed message regexp, expanded for the text of this tag. */
private Pattern tagMessageRegexp;
private final Pattern tagMessageRegexp;
/**
* Constructs a tag.
@ -343,6 +343,9 @@ public class SuppressionCommentFilter
expandFromCoont(text, filter.messageFormat, filter.onRegexp);
tagMessageRegexp = Pattern.compile(format);
}
else {
tagMessageRegexp = null;
}
}
else {
format =
@ -356,6 +359,9 @@ public class SuppressionCommentFilter
filter.offRegexp);
tagMessageRegexp = Pattern.compile(format);
}
else {
tagMessageRegexp = null;
}
}
}
catch (final PatternSyntaxException e) {