summaryrefslogtreecommitdiff
path: root/linter/LongLineCheck.java
blob: d5d4368f4f12f1562acb5f073805ff75585f844e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Nik Johnson
// 2-24-2024
// TA: Andy Ruan

import java.util.*;

// long line checker
public class LongLineCheck implements Check {

    // if the line being checked is 100 characters or longer, return a new error (code 1)
    // takes line and line number
    // returns error inside optional
    public Optional<Error> lint(String line, int lineNumber) {
        if (line.length() >= 100) {
            return Optional.of(new Error(1, lineNumber, 
            "Line length exceeded maximum length of 100 characters"));
        }

        return Optional.empty();
    }
}