комментарии и сообщения переведены на английский
- комментарии, тексты ошибок, вывод CLI и сообщения тестов теперь на английском - по-русски остались только литералы словаря ru и содержимое фикстур: это данные под проверкой, а не текст инструмента - согласование числительных в итоге упростилось до английского plural
This commit is contained in:
+26
-26
@@ -1,11 +1,11 @@
|
||||
// Package check прогоняет проверки целостности набора.
|
||||
// Package check runs the integrity checks of a suite.
|
||||
//
|
||||
// Деление на семейства взято из языка и сохранено в коде: форма правила
|
||||
// проверяется в любом файле, который язык употребляет; распространение — только
|
||||
// в файлах конвенций, потому что эти проверки о том, что документ уезжает к
|
||||
// потребителю. Третья часть списка — взаимоисключительность строк таблицы,
|
||||
// покрытие области действия, самодостаточность нормы — сюда не входит: она не
|
||||
// даётся разбором текста и остаётся работой читателя.
|
||||
// The split into families is taken from the language and kept in the code: the
|
||||
// form of a rule is checked in any file the language employs; spread only in
|
||||
// convention files, because those checks are about a document travelling to a
|
||||
// consumer. The third part of the list — rows of a table being mutually
|
||||
// exclusive, the scope being covered, a norm being self-sufficient — is not
|
||||
// here: it does not yield to parsing text and stays the reader's work.
|
||||
package check
|
||||
|
||||
import (
|
||||
@@ -13,8 +13,8 @@ import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
// Severity различает ошибку и предупреждение. Ошибка — нарушение, названное
|
||||
// правилом набора; предупреждение — то, что стоит посмотреть глазами.
|
||||
// Severity tells an error from a warning. An error is a violation named by a
|
||||
// rule of the suite; a warning is something worth a look.
|
||||
type Severity int
|
||||
|
||||
const (
|
||||
@@ -24,43 +24,44 @@ const (
|
||||
|
||||
func (s Severity) String() string {
|
||||
if s == Warning {
|
||||
return "предупреждение"
|
||||
return "warning"
|
||||
}
|
||||
return "ошибка"
|
||||
return "error"
|
||||
}
|
||||
|
||||
// Family — семейство проверок, из которого пришла находка.
|
||||
// Family is the family of checks a finding came from.
|
||||
type Family string
|
||||
|
||||
const (
|
||||
Manifest Family = "манифест"
|
||||
Form Family = "форма"
|
||||
Spread Family = "распространение"
|
||||
Links Family = "ссылки"
|
||||
Manifest Family = "manifest"
|
||||
Form Family = "form"
|
||||
Spread Family = "spread"
|
||||
Links Family = "links"
|
||||
)
|
||||
|
||||
// Finding — одна находка.
|
||||
// Finding is a single finding.
|
||||
type Finding struct {
|
||||
Severity Severity
|
||||
Family Family
|
||||
// Path — путь файла от корня набора; пусто, если находка о наборе целиком.
|
||||
// Path is the path of the file from the root of the suite; empty when the
|
||||
// finding is about the suite as a whole.
|
||||
Path string
|
||||
// Line — строка файла; ноль, если находка не привязана к строке.
|
||||
// Line is the line of the file; zero when the finding is not bound to one.
|
||||
Line int
|
||||
Msg string
|
||||
}
|
||||
|
||||
// Report накапливает находки одного прогона.
|
||||
// Report accumulates the findings of one run.
|
||||
type Report struct {
|
||||
findings []Finding
|
||||
}
|
||||
|
||||
// Errorf записывает ошибку.
|
||||
// Errorf records an error.
|
||||
func (r *Report) Errorf(f Family, path string, line int, format string, args ...any) {
|
||||
r.add(Error, f, path, line, format, args...)
|
||||
}
|
||||
|
||||
// Warnf записывает предупреждение.
|
||||
// Warnf records a warning.
|
||||
func (r *Report) Warnf(f Family, path string, line int, format string, args ...any) {
|
||||
r.add(Warning, f, path, line, format, args...)
|
||||
}
|
||||
@@ -75,8 +76,7 @@ func (r *Report) add(s Severity, f Family, path string, line int, format string,
|
||||
})
|
||||
}
|
||||
|
||||
// Findings отдаёт находки в порядке файла и строки. Находки о наборе целиком
|
||||
// идут первыми: пока манифест не сходится, остальное читать рано.
|
||||
// Findings hands over the findings ordered by file and line.
|
||||
func (r *Report) Findings() []Finding {
|
||||
out := make([]Finding, len(r.findings))
|
||||
copy(out, r.findings)
|
||||
@@ -89,7 +89,7 @@ func (r *Report) Findings() []Finding {
|
||||
return out
|
||||
}
|
||||
|
||||
// Errors считает находки уровня ошибки.
|
||||
// Errors counts the findings of error severity.
|
||||
func (r *Report) Errors() int {
|
||||
n := 0
|
||||
for _, f := range r.findings {
|
||||
@@ -100,7 +100,7 @@ func (r *Report) Errors() int {
|
||||
return n
|
||||
}
|
||||
|
||||
// Warnings считает предупреждения.
|
||||
// Warnings counts the warnings.
|
||||
func (r *Report) Warnings() int {
|
||||
return len(r.findings) - r.Errors()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user