Code cleanup.

This commit is contained in:
Erik C. Thauvin 2022-01-30 09:21:41 -08:00
parent 7854faaa9c
commit 93fad0cb72
4 changed files with 25 additions and 23 deletions

View file

@ -36,8 +36,6 @@ class CatResult {
/// The list of errors.
final List<CatError> errors = [];
CatResult();
/// Returns `true` if the [exitCode] is [exitFailure].
bool get isFailure => exitCode == exitFailure;
@ -47,11 +45,7 @@ class CatResult {
/// Adds an error [message] and [path].
void addError(String message, {String? path}) {
exitCode = exitFailure;
if (path != null && path.isNotEmpty) {
errors.add(CatError(message, path: path));
} else {
errors.add(CatError(message));
}
errors.add(CatError(message, path: path));
}
}
@ -147,11 +141,10 @@ Future<void> _copyStream(
squeeze = 0;
}
}
if (showLineNumbers || numberNonBlank) {
if (!numberNonBlank || ch != _lineFeed) {
buff.addAll('${++lastLine.lineNumber}'.padLeft(6).codeUnits);
buff.add(tab);
}
if ((showLineNumbers || numberNonBlank) &&
(!numberNonBlank || ch != _lineFeed)) {
buff.addAll('${++lastLine.lineNumber}'.padLeft(6).codeUnits);
buff.add(tab);
}
}
lastLine.lastChar = ch;