-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnostic_codes.go
More file actions
100 lines (77 loc) · 3.17 KB
/
diagnostic_codes.go
File metadata and controls
100 lines (77 loc) · 3.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// SPDX-License-Identifier: MIT
// Copyright (c) 2026 WoozyMasta
// Source: github.com/woozymasta/stringtable
package stringtable
import (
"github.com/woozymasta/lintkit/lint"
)
const (
// LintModule is stable lint module namespace for stringtable rules.
LintModule = "stringtable"
// LintFileKindCSV is lint file kind token for stringtable CSV files.
LintFileKindCSV lint.FileKind = "stringtable.csv"
)
const (
// StageLint marks stringtable CSV lint diagnostics.
StageLint lint.Stage = "csv"
)
const (
// CodeLintEmptyHeaderLanguage reports empty language column name in header.
CodeLintEmptyHeaderLanguage lint.Code = 2001
// CodeLintDuplicateHeaderLanguage reports duplicate language columns in header.
CodeLintDuplicateHeaderLanguage lint.Code = 2002
// CodeLintUnknownHeaderLanguage reports unknown language column in header.
CodeLintUnknownHeaderLanguage lint.Code = 2003
// CodeLintMissingDefaultLanguages reports missing default language columns.
CodeLintMissingDefaultLanguages lint.Code = 2004
// CodeLintRowColumnCountMismatch reports row/header column count mismatch.
CodeLintRowColumnCountMismatch lint.Code = 2005
// CodeLintDuplicateKey reports duplicate key values in data rows.
CodeLintDuplicateKey lint.Code = 2006
// CodeLintKeyTrimMismatch reports key values with leading/trailing spaces.
CodeLintKeyTrimMismatch lint.Code = 2007
// CodeLintInvalidKeyPattern reports translation key token format mismatch.
CodeLintInvalidKeyPattern lint.Code = 2008
// CodeLintOriginalEmpty reports empty value in required original column.
CodeLintOriginalEmpty lint.Code = 2009
// CodeLintTranslationEmpty reports empty value in translation columns.
CodeLintTranslationEmpty lint.Code = 2010
// CodeLintUnquotedNonKeyColumn reports unquoted non-key CSV columns.
CodeLintUnquotedNonKeyColumn lint.Code = 2011
)
const (
// DefaultKeyPattern is default regexp for translation key values.
DefaultKeyPattern = "^[-_A-Za-z0-9]+$"
)
var diagnosticCodeCatalogHandle = lint.NewCodeCatalogHandle(
lint.CodeCatalogConfig{
Module: LintModule,
CodePrefix: "STBL",
ModuleName: "DayZ stringtable",
ModuleDescription: "Lint rules for DayZ stringtable CSV files.",
ScopeDescriptions: map[lint.Stage]string{
StageLint: "Stringtable CSV structure and translation diagnostics.",
},
},
diagnosticCatalog,
)
// getDiagnosticCodeCatalog returns lazy-initialized code catalog helper.
func getDiagnosticCodeCatalog() (lint.CodeCatalog, error) {
return diagnosticCodeCatalogHandle.Catalog()
}
// DiagnosticCatalog returns stable diagnostics metadata list.
func DiagnosticCatalog() []lint.CodeSpec {
return diagnosticCodeCatalogHandle.CodeSpecs()
}
// DiagnosticByCode returns diagnostic metadata for stable code.
func DiagnosticByCode(code lint.Code) (lint.CodeSpec, bool) {
return diagnosticCodeCatalogHandle.ByCode(code)
}
// LintRuleID returns lint rule ID mapped from stable stringtable code.
func LintRuleID(code lint.Code) string {
return diagnosticCodeCatalogHandle.RuleIDOrUnknown(code)
}
// LintRuleSpecs returns deterministic lint rule specs from diagnostics catalog.
func LintRuleSpecs() []lint.RuleSpec {
return diagnosticCodeCatalogHandle.RuleSpecs()
}