init
This commit is contained in:
23
linter/BreakCheck.java
Normal file
23
linter/BreakCheck.java
Normal file
@@ -0,0 +1,23 @@
|
||||
// Nik Johnson
|
||||
// 2-24-2024
|
||||
// TA: Andy Ruan
|
||||
|
||||
import java.util.*;
|
||||
|
||||
// checks Strings for the characters "break" that come BEFORE the characters "//"
|
||||
public class BreakCheck implements Check {
|
||||
|
||||
// if the line being checked has "break" in it
|
||||
// after removing all single line comments, return a new error (code 2)
|
||||
// takes line and line number
|
||||
// returns error inside optional
|
||||
public Optional<Error> lint(String line, int lineNumber) {
|
||||
String input = line;
|
||||
String output = input.replaceAll("//.*", "");
|
||||
|
||||
if (output.contains("break")) {
|
||||
return Optional.of(new Error(2, lineNumber, "we cant use break in this class bro"));
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user