Skip to content

Commit

Permalink
замечания из ПР
Browse files Browse the repository at this point in the history
  • Loading branch information
artbear committed Nov 26, 2023
1 parent 8763be8 commit 1009afa
Showing 1 changed file with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class BadWordsDiagnostic extends AbstractDiagnostic {

private static final String BAD_WORDS_DEFAULT = "";
private static final boolean FIND_IN_COMMENTS = true;
private static final boolean FIND_IN_COMMENTS_DEFAULT = true;

@DiagnosticParameter(
type = String.class,
Expand All @@ -58,15 +58,15 @@ public class BadWordsDiagnostic extends AbstractDiagnostic {

@DiagnosticParameter(
type = Boolean.class,
defaultValue = "" + FIND_IN_COMMENTS
defaultValue = "" + FIND_IN_COMMENTS_DEFAULT
)
private boolean findInComments = FIND_IN_COMMENTS;
private boolean findInComments = FIND_IN_COMMENTS_DEFAULT;

@Override
public void configure(Map<String, Object> configuration) {
this.badWords = CaseInsensitivePattern.compile(
(String) configuration.getOrDefault("badWords", BAD_WORDS_DEFAULT));
this.findInComments = (boolean) configuration.getOrDefault("findInComments", FIND_IN_COMMENTS);
this.findInComments = (boolean) configuration.getOrDefault("findInComments", FIND_IN_COMMENTS_DEFAULT);
}

@Override
Expand All @@ -78,7 +78,7 @@ protected void check() {

var moduleLines = getContentList();
for (var i = 0; i < moduleLines.length; i++) {
final var moduleLine = moduleLines[i];
var moduleLine = moduleLines[i];
if (moduleLine.isEmpty()) {
continue;
}
Expand All @@ -93,15 +93,15 @@ protected void check() {
}

private String[] getContentList() {
final var moduleLines = documentContext.getContentList();
var moduleLines = documentContext.getContentList();
if (findInComments) {
return moduleLines;
}
final var lineNumbersWithoutComments = getLineNumbersWithoutComments();
var lineNumbersWithoutComments = getLineNumbersWithoutComments();
if (lineNumbersWithoutComments.isEmpty()) {
return moduleLines;
}
final List<String> result = new ArrayList<>(lineNumbersWithoutComments.size());
List<String> result = new ArrayList<>(lineNumbersWithoutComments.size());
for (var i = 0; i < moduleLines.length; i++) {
if (lineNumbersWithoutComments.contains(i)) {
result.add(moduleLines[i]);
Expand All @@ -114,7 +114,7 @@ private String[] getContentList() {

private Set<Integer> getLineNumbersWithoutComments() {
var result = new HashSet<Integer>();
final var tokens = documentContext.getTokensFromDefaultChannel();
var tokens = documentContext.getTokensFromDefaultChannel();
int lastLine = -1;
for (var token : tokens) {
var line = token.getLine();
Expand Down

0 comments on commit 1009afa

Please sign in to comment.