All files / src/checker/checks/generic oddCodePoint.ts

100% Statements 10/10
100% Branches 4/4
100% Functions 2/2
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23  2x       4x   3x   3x 94x   94x 1x 1x     2x       2x  
import { Query } from "../../../reader/query";
import { CheckerResult } from "../../checkerResult";
import { IChecker } from "../../interface";
 
class OddCodePoint implements IChecker {
  public message = "Bad code point";
  public check(query: Query): CheckerResult {
    const badCodePoints = [65533];
 
    for (const char of query.getContent()) {
      const codePoint = char.codePointAt(0);
 
      if (codePoint !== undefined && badCodePoints.includes(codePoint)) {
        const lineNumber = query.lines[0].num;
        return new CheckerResult(lineNumber, this.message);
      }
    }
    return new CheckerResult(0, "");
  }
}
 
export { OddCodePoint };