@iris-code/core 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +38 -0
- package/dist/config.d.ts +147 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +550 -0
- package/dist/config.js.map +1 -0
- package/dist/csharp/analyser.d.ts +14 -0
- package/dist/csharp/analyser.d.ts.map +1 -0
- package/dist/csharp/analyser.js +436 -0
- package/dist/csharp/analyser.js.map +1 -0
- package/dist/csharp/lexer.d.ts +29 -0
- package/dist/csharp/lexer.d.ts.map +1 -0
- package/dist/csharp/lexer.js +182 -0
- package/dist/csharp/lexer.js.map +1 -0
- package/dist/duplicates.d.ts +53 -0
- package/dist/duplicates.d.ts.map +1 -0
- package/dist/duplicates.js +491 -0
- package/dist/duplicates.js.map +1 -0
- package/dist/fileAnalyser.d.ts +4 -0
- package/dist/fileAnalyser.d.ts.map +1 -0
- package/dist/fileAnalyser.js +8 -0
- package/dist/fileAnalyser.js.map +1 -0
- package/dist/fileNaming.d.ts +68 -0
- package/dist/fileNaming.d.ts.map +1 -0
- package/dist/fileNaming.js +343 -0
- package/dist/fileNaming.js.map +1 -0
- package/dist/gate.d.ts +49 -0
- package/dist/gate.d.ts.map +1 -0
- package/dist/gate.js +242 -0
- package/dist/gate.js.map +1 -0
- package/dist/go/analyser.d.ts +5 -0
- package/dist/go/analyser.d.ts.map +1 -0
- package/dist/go/analyser.js +576 -0
- package/dist/go/analyser.js.map +1 -0
- package/dist/guards.d.ts +16 -0
- package/dist/guards.d.ts.map +1 -0
- package/dist/guards.js +355 -0
- package/dist/guards.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/languages.d.ts +46 -0
- package/dist/languages.d.ts.map +1 -0
- package/dist/languages.js +155 -0
- package/dist/languages.js.map +1 -0
- package/dist/lines.d.ts +9 -0
- package/dist/lines.d.ts.map +1 -0
- package/dist/lines.js +58 -0
- package/dist/lines.js.map +1 -0
- package/dist/python/analyser.d.ts +5 -0
- package/dist/python/analyser.d.ts.map +1 -0
- package/dist/python/analyser.js +630 -0
- package/dist/python/analyser.js.map +1 -0
- package/dist/qualitySignals.d.ts +30 -0
- package/dist/qualitySignals.d.ts.map +1 -0
- package/dist/qualitySignals.js +101 -0
- package/dist/qualitySignals.js.map +1 -0
- package/dist/ruby/analyser.d.ts +5 -0
- package/dist/ruby/analyser.d.ts.map +1 -0
- package/dist/ruby/analyser.js +450 -0
- package/dist/ruby/analyser.js.map +1 -0
- package/dist/scoring.d.ts +4 -0
- package/dist/scoring.d.ts.map +1 -0
- package/dist/scoring.js +37 -0
- package/dist/scoring.js.map +1 -0
- package/dist/secrets.d.ts +5 -0
- package/dist/secrets.d.ts.map +1 -0
- package/dist/secrets.js +245 -0
- package/dist/secrets.js.map +1 -0
- package/dist/securityContext.d.ts +2 -0
- package/dist/securityContext.d.ts.map +1 -0
- package/dist/securityContext.js +16 -0
- package/dist/securityContext.js.map +1 -0
- package/dist/sfc.d.ts +32 -0
- package/dist/sfc.d.ts.map +1 -0
- package/dist/sfc.js +228 -0
- package/dist/sfc.js.map +1 -0
- package/dist/slop.d.ts +37 -0
- package/dist/slop.d.ts.map +1 -0
- package/dist/slop.js +81 -0
- package/dist/slop.js.map +1 -0
- package/dist/suppressions.d.ts +19 -0
- package/dist/suppressions.d.ts.map +1 -0
- package/dist/suppressions.js +152 -0
- package/dist/suppressions.js.map +1 -0
- package/dist/ts/analyser.d.ts +4 -0
- package/dist/ts/analyser.d.ts.map +1 -0
- package/dist/ts/analyser.js +769 -0
- package/dist/ts/analyser.js.map +1 -0
- package/dist/types.d.ts +139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +46 -0
- package/dist/types.js.map +1 -0
- package/package.json +43 -0
package/dist/guards.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FileAnalysis, Language } from './types';
|
|
2
|
+
import { IrisConfig } from './config';
|
|
3
|
+
export type AnalyseBufferResult = {
|
|
4
|
+
kind: 'analysis';
|
|
5
|
+
analysis: FileAnalysis;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'skip';
|
|
8
|
+
reason: 'binary-file';
|
|
9
|
+
};
|
|
10
|
+
export declare function detectLanguage(filePath: string, source?: string): Language;
|
|
11
|
+
export declare function isTestFile(filePath: string): boolean;
|
|
12
|
+
export declare function looksLikeBinary(buffer: Uint8Array): boolean;
|
|
13
|
+
export declare function createParseErrorAnalysis(language: Language, reason: string, source?: string): FileAnalysis;
|
|
14
|
+
export declare function detectParseErrorReason(source: string, filePath: string): string | null;
|
|
15
|
+
export declare function normaliseConfig(config: Partial<IrisConfig> | IrisConfig): IrisConfig;
|
|
16
|
+
//# sourceMappingURL=guards.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAoB,MAAM,SAAS,CAAA;AAClE,OAAO,EAAuB,UAAU,EAAE,MAAM,UAAU,CAAA;AAI1D,MAAM,MAAM,mBAAmB,GAC3B;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,YAAY,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,CAAA;AAE3C,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,QAAQ,CAE1E;AAiBD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAa3D;AAED,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,MAAM,EACd,MAAM,SAAK,GACV,YAAY,CAuDd;AAsHD,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiHtF;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,UAAU,GAAG,UAAU,CAapF"}
|
package/dist/guards.js
ADDED
|
@@ -0,0 +1,355 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.detectLanguage = detectLanguage;
|
|
4
|
+
exports.isTestFile = isTestFile;
|
|
5
|
+
exports.looksLikeBinary = looksLikeBinary;
|
|
6
|
+
exports.createParseErrorAnalysis = createParseErrorAnalysis;
|
|
7
|
+
exports.detectParseErrorReason = detectParseErrorReason;
|
|
8
|
+
exports.normaliseConfig = normaliseConfig;
|
|
9
|
+
const config_1 = require("./config");
|
|
10
|
+
const lexer_1 = require("./csharp/lexer");
|
|
11
|
+
const languages_1 = require("./languages");
|
|
12
|
+
function detectLanguage(filePath, source) {
|
|
13
|
+
return (0, languages_1.languageKeyForFile)(filePath, source);
|
|
14
|
+
}
|
|
15
|
+
// Recognises common test-file conventions across the supported languages.
|
|
16
|
+
// Used to relax the suspicious-name secret heuristic (Layer 1) inside tests,
|
|
17
|
+
// where fixture credentials like password="secret123" are expected and not real.
|
|
18
|
+
const TEST_FILENAME_RE = /(^test_.*\.py$|_test\.py$|^conftest\.py$|_test\.go$|_(?:test|spec)\.rb$|\.(test|spec)\.(js|jsx|ts|tsx|mjs|cjs)$)/;
|
|
19
|
+
const TEST_DIR_RE = /(^|\/)(tests?|__tests__|__mocks__|spec|e2e)(\/|$)/;
|
|
20
|
+
// C# has no filename separator for tests: xUnit/NUnit/MSTest name the file after
|
|
21
|
+
// the type under test with a Tests/Test/Spec suffix, and the project directory
|
|
22
|
+
// is <Something>.Tests rather than `tests`. Matched CASE-SENSITIVELY on the
|
|
23
|
+
// PascalCase suffix, because lowercasing first would also claim Contests.cs and
|
|
24
|
+
// Protests.cs. Without this, every fixture credential and every localhost test
|
|
25
|
+
// URL in a .NET test project reads as a production finding.
|
|
26
|
+
const CSHARP_TEST_FILENAME_RE = /(?:Tests?|Specs?|Fixture)\.cs$|\.(?:Tests?|Specs?)\.csproj$/;
|
|
27
|
+
const CSHARP_TEST_DIR_RE = /(?:^|\/)[\w.]*\.(?:Tests?|Specs?|IntegrationTests?|UnitTests?|FunctionalTests?|AcceptanceTests?|Testing)(?:\/|$)/;
|
|
28
|
+
function isTestFile(filePath) {
|
|
29
|
+
const withSlashes = filePath.replace(/\\/g, '/');
|
|
30
|
+
const normalised = withSlashes.toLowerCase();
|
|
31
|
+
const base = normalised.slice(normalised.lastIndexOf('/') + 1);
|
|
32
|
+
if (TEST_FILENAME_RE.test(base) || TEST_DIR_RE.test(normalised))
|
|
33
|
+
return true;
|
|
34
|
+
const rawBase = withSlashes.slice(withSlashes.lastIndexOf('/') + 1);
|
|
35
|
+
return CSHARP_TEST_FILENAME_RE.test(rawBase) || CSHARP_TEST_DIR_RE.test(withSlashes);
|
|
36
|
+
}
|
|
37
|
+
function looksLikeBinary(buffer) {
|
|
38
|
+
const sample = buffer.subarray(0, Math.min(buffer.length, 512));
|
|
39
|
+
if (sample.length === 0)
|
|
40
|
+
return false;
|
|
41
|
+
let suspicious = 0;
|
|
42
|
+
for (const byte of sample) {
|
|
43
|
+
if (byte === 0)
|
|
44
|
+
return true;
|
|
45
|
+
const isControl = byte < 7 || (byte > 14 && byte < 32) || byte === 127;
|
|
46
|
+
if (isControl)
|
|
47
|
+
suspicious++;
|
|
48
|
+
}
|
|
49
|
+
return suspicious / sample.length > 0.2;
|
|
50
|
+
}
|
|
51
|
+
function createParseErrorAnalysis(language, reason, source = '') {
|
|
52
|
+
const rawLines = source === '' ? [] : source.split('\n');
|
|
53
|
+
const lineCount = rawLines.length;
|
|
54
|
+
const blankLines = rawLines.filter(line => line.trim() === '').length;
|
|
55
|
+
const codeLines = Math.max(0, lineCount - blankLines);
|
|
56
|
+
const base = {
|
|
57
|
+
lineCount,
|
|
58
|
+
blankLines,
|
|
59
|
+
codeLines,
|
|
60
|
+
functions: [],
|
|
61
|
+
thirdPartyImports: [],
|
|
62
|
+
unusedImports: [],
|
|
63
|
+
complexityScore: 0,
|
|
64
|
+
warnings: [
|
|
65
|
+
{
|
|
66
|
+
type: 'parse-error',
|
|
67
|
+
message: reason,
|
|
68
|
+
severity: 'error',
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
typeScriptMetrics: {
|
|
72
|
+
anyUsages: [],
|
|
73
|
+
tsIgnoreCount: 0,
|
|
74
|
+
tsExpectErrorCount: 0,
|
|
75
|
+
nonNullAssertions: 0,
|
|
76
|
+
typeAssertions: 0,
|
|
77
|
+
missingReturnTypes: 0,
|
|
78
|
+
},
|
|
79
|
+
codeSmells: {
|
|
80
|
+
consoleLogs: [],
|
|
81
|
+
todos: [],
|
|
82
|
+
deepNesting: 0,
|
|
83
|
+
longParameterLists: [],
|
|
84
|
+
magicNumbers: [],
|
|
85
|
+
unusedVars: [],
|
|
86
|
+
unusedFunctions: [],
|
|
87
|
+
hardcodedSecrets: [],
|
|
88
|
+
evalUsage: [],
|
|
89
|
+
sqlConcatenation: [],
|
|
90
|
+
insecureRandom: [],
|
|
91
|
+
unsafeRegex: [],
|
|
92
|
+
hardcodedLocalhost: [],
|
|
93
|
+
disabledTlsVerification: [],
|
|
94
|
+
debugFlagsEnabled: [],
|
|
95
|
+
weakHashing: [],
|
|
96
|
+
openRedirect: [],
|
|
97
|
+
bareSuppressions: [],
|
|
98
|
+
duplicateBlocks: [],
|
|
99
|
+
fileNamingViolations: [],
|
|
100
|
+
},
|
|
101
|
+
healthScore: 0,
|
|
102
|
+
};
|
|
103
|
+
return { language, suppressed: [], ...base };
|
|
104
|
+
}
|
|
105
|
+
function stripQuotedText(source) {
|
|
106
|
+
let result = '';
|
|
107
|
+
let i = 0;
|
|
108
|
+
while (i < source.length) {
|
|
109
|
+
const triple = source.slice(i, i + 3);
|
|
110
|
+
if (triple === '"""' || triple === "'''") {
|
|
111
|
+
result += ' ';
|
|
112
|
+
i += 3;
|
|
113
|
+
while (i < source.length) {
|
|
114
|
+
const currentTriple = source.slice(i, i + 3);
|
|
115
|
+
if (currentTriple === triple) {
|
|
116
|
+
result += ' ';
|
|
117
|
+
i += 3;
|
|
118
|
+
break;
|
|
119
|
+
}
|
|
120
|
+
result += source[i] === '\n' ? '\n' : ' ';
|
|
121
|
+
i++;
|
|
122
|
+
}
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
const ch = source[i];
|
|
126
|
+
if (ch !== '"' && ch !== "'" && ch !== '`') {
|
|
127
|
+
result += ch;
|
|
128
|
+
i++;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
result += ' ';
|
|
132
|
+
i++;
|
|
133
|
+
while (i < source.length) {
|
|
134
|
+
const current = source[i];
|
|
135
|
+
if (current === '\n') {
|
|
136
|
+
result += '\n';
|
|
137
|
+
i++;
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (current === '\\') {
|
|
141
|
+
result += ' ';
|
|
142
|
+
if (i + 1 < source.length) {
|
|
143
|
+
result += source[i + 1] === '\n' ? '\n' : ' ';
|
|
144
|
+
}
|
|
145
|
+
i += 2;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
result += ' ';
|
|
149
|
+
i++;
|
|
150
|
+
if (current === ch)
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return result;
|
|
155
|
+
}
|
|
156
|
+
function stripComments(source) {
|
|
157
|
+
let result = '';
|
|
158
|
+
let i = 0;
|
|
159
|
+
while (i < source.length) {
|
|
160
|
+
const ch = source[i];
|
|
161
|
+
if (ch === '"' || ch === "'" || ch === '`') {
|
|
162
|
+
result += ch;
|
|
163
|
+
i++;
|
|
164
|
+
while (i < source.length) {
|
|
165
|
+
const current = source[i];
|
|
166
|
+
result += current;
|
|
167
|
+
if (current === '\\') {
|
|
168
|
+
i++;
|
|
169
|
+
if (i < source.length)
|
|
170
|
+
result += source[i];
|
|
171
|
+
}
|
|
172
|
+
else if (current === ch) {
|
|
173
|
+
i++;
|
|
174
|
+
break;
|
|
175
|
+
}
|
|
176
|
+
i++;
|
|
177
|
+
}
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if (ch === '/' && source[i + 1] === '/') {
|
|
181
|
+
while (i < source.length && source[i] !== '\n') {
|
|
182
|
+
result += ' ';
|
|
183
|
+
i++;
|
|
184
|
+
}
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
if (ch === '/' && source[i + 1] === '*') {
|
|
188
|
+
result += ' ';
|
|
189
|
+
i += 2;
|
|
190
|
+
while (i < source.length) {
|
|
191
|
+
if (source[i] === '*' && source[i + 1] === '/') {
|
|
192
|
+
result += ' ';
|
|
193
|
+
i += 2;
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
result += source[i] === '\n' ? '\n' : ' ';
|
|
197
|
+
i++;
|
|
198
|
+
}
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
if (ch === '#') {
|
|
202
|
+
while (i < source.length && source[i] !== '\n') {
|
|
203
|
+
result += ' ';
|
|
204
|
+
i++;
|
|
205
|
+
}
|
|
206
|
+
continue;
|
|
207
|
+
}
|
|
208
|
+
result += ch;
|
|
209
|
+
i++;
|
|
210
|
+
}
|
|
211
|
+
return result;
|
|
212
|
+
}
|
|
213
|
+
// Ruby keywords that are block openers at the start of a statement and inert
|
|
214
|
+
// modifiers when they trail an expression. `class`/`module`/`def`/`case`/`begin`
|
|
215
|
+
// are excluded: they always open, wherever they appear.
|
|
216
|
+
const MODIFIABLE_RUBY_KEYWORDS = new Set(['if', 'unless', 'while', 'until', 'for']);
|
|
217
|
+
function detectParseErrorReason(source, filePath) {
|
|
218
|
+
const language = detectLanguage(filePath);
|
|
219
|
+
// C# needs its OWN sanitiser before the delimiter balance is trusted. The
|
|
220
|
+
// generic one treats `\"` as an escaped quote, so the everyday verbatim string
|
|
221
|
+
// `@"C:\logs\"` read as unterminated, every brace after it counted at the
|
|
222
|
+
// wrong depth, and the file was reported as a parse error with every finding
|
|
223
|
+
// zeroed. Raw strings ("""{ "a": 1 }""") failed the same way, in the other
|
|
224
|
+
// direction: their braces were counted as code.
|
|
225
|
+
const sanitized = language === 'csharp'
|
|
226
|
+
? (0, lexer_1.csharpCodeOnly)(source)
|
|
227
|
+
: stripQuotedText(stripComments(source));
|
|
228
|
+
// A .csproj is XML: angle brackets, not braces, and MSBuild conditions carry
|
|
229
|
+
// unbalanced parentheses in attribute values often enough that the check
|
|
230
|
+
// would produce nothing but noise.
|
|
231
|
+
if (filePath.toLowerCase().endsWith('.csproj'))
|
|
232
|
+
return null;
|
|
233
|
+
const stack = [];
|
|
234
|
+
const openers = new Map([
|
|
235
|
+
['(', ')'],
|
|
236
|
+
['{', '}'],
|
|
237
|
+
['[', ']'],
|
|
238
|
+
]);
|
|
239
|
+
const closers = new Map([
|
|
240
|
+
[')', '('],
|
|
241
|
+
['}', '{'],
|
|
242
|
+
[']', '['],
|
|
243
|
+
]);
|
|
244
|
+
for (let i = 0; i < sanitized.length; i++) {
|
|
245
|
+
const ch = sanitized[i];
|
|
246
|
+
if (openers.has(ch)) {
|
|
247
|
+
stack.push(ch);
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
if (closers.has(ch)) {
|
|
251
|
+
const expected = closers.get(ch);
|
|
252
|
+
const actual = stack.pop();
|
|
253
|
+
if (actual !== expected) {
|
|
254
|
+
return `Parse error: mismatched delimiter '${ch}'`;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (stack.length > 0) {
|
|
259
|
+
return `Parse error: unclosed delimiter '${stack[stack.length - 1]}'`;
|
|
260
|
+
}
|
|
261
|
+
if (language === 'python') {
|
|
262
|
+
// A block header (def/class/if/for/with/...) must carry a ':' that closes
|
|
263
|
+
// its header. But the header can legally wrap across physical lines inside
|
|
264
|
+
// brackets - a long signature or condition - in which case the ':' lands on
|
|
265
|
+
// a later line. Track bracket depth so we only validate headers that begin
|
|
266
|
+
// and complete on a single physical line; wrapped headers and their
|
|
267
|
+
// continuation lines are skipped instead of being flagged as syntax errors.
|
|
268
|
+
const blockKw = /^(def|class|if|elif|else|for|while|try|except|finally|with|match)\b/;
|
|
269
|
+
let depth = 0;
|
|
270
|
+
for (const line of sanitized.split('\n')) {
|
|
271
|
+
const startDepth = depth;
|
|
272
|
+
let hasTopLevelColon = false;
|
|
273
|
+
for (const ch of line) {
|
|
274
|
+
if (ch === '(' || ch === '[' || ch === '{')
|
|
275
|
+
depth++;
|
|
276
|
+
else if (ch === ')' || ch === ']' || ch === '}')
|
|
277
|
+
depth = Math.max(0, depth - 1);
|
|
278
|
+
else if (ch === ':' && depth === 0)
|
|
279
|
+
hasTopLevelColon = true;
|
|
280
|
+
}
|
|
281
|
+
if (startDepth !== 0)
|
|
282
|
+
continue; // continuation of a wrapped statement
|
|
283
|
+
const trimmed = line.trim();
|
|
284
|
+
if (!trimmed || !blockKw.test(trimmed))
|
|
285
|
+
continue;
|
|
286
|
+
if (depth !== 0)
|
|
287
|
+
continue; // header continues onto the next line
|
|
288
|
+
if (trimmed.endsWith('\\'))
|
|
289
|
+
continue; // explicit line continuation
|
|
290
|
+
if (!hasTopLevelColon) {
|
|
291
|
+
return 'Parse error: expected trailing colon';
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (language === 'ruby') {
|
|
296
|
+
const stack = [];
|
|
297
|
+
for (const rawLine of sanitized.split('\n')) {
|
|
298
|
+
const line = rawLine.trim();
|
|
299
|
+
if (!line)
|
|
300
|
+
continue;
|
|
301
|
+
// Ruby has no statement terminator, so a keyword's MEANING depends on where
|
|
302
|
+
// it sits. `if` at the start of a statement opens a block that needs an
|
|
303
|
+
// `end`; the identical token trailing an expression is a modifier that needs
|
|
304
|
+
// none, and `return x if y` is the most common line in idiomatic Ruby. The
|
|
305
|
+
// match must also ignore `:if`/`.end`, where the keyword is a symbol or a
|
|
306
|
+
// method name (Range#end) rather than a keyword at all.
|
|
307
|
+
const beginsLoop = /^(?:while|until|for)\b/.test(line);
|
|
308
|
+
const pattern = /(^|[^.:\w])(class|module|def|if|unless|case|begin|while|until|for|do|end)\b/g;
|
|
309
|
+
let match;
|
|
310
|
+
while ((match = pattern.exec(line)) !== null) {
|
|
311
|
+
const token = match[2];
|
|
312
|
+
const before = line.slice(0, match.index + match[1].length).trim();
|
|
313
|
+
// A statement starts at the line start, after a `;` separator, or after an
|
|
314
|
+
// assignment/logical operator - `label = if cond` is a real block opener.
|
|
315
|
+
const atStatementStart = before === '' || /(?:^|[;=(]|&&|\|\||\band\b|\bor\b|\bthen\b)$/.test(before);
|
|
316
|
+
if (token === 'end') {
|
|
317
|
+
if (stack.length === 0)
|
|
318
|
+
return "Parse error: unexpected 'end'";
|
|
319
|
+
stack.pop();
|
|
320
|
+
}
|
|
321
|
+
else if (token === 'def' && /^def\b.*?\s=\s/.test(line)) {
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
else if (token === 'do' && beginsLoop) {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
else if (MODIFIABLE_RUBY_KEYWORDS.has(token) && !atStatementStart) {
|
|
328
|
+
// Trailing modifier (`return 1 if n`, `end while i < n`) - opens nothing.
|
|
329
|
+
continue;
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
stack.push(token);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (stack.length > 0)
|
|
337
|
+
return `Parse error: missing 'end' for ${stack[stack.length - 1]}`;
|
|
338
|
+
}
|
|
339
|
+
return null;
|
|
340
|
+
}
|
|
341
|
+
function normaliseConfig(config) {
|
|
342
|
+
return {
|
|
343
|
+
...config_1.DEFAULT_IRIS_CONFIG,
|
|
344
|
+
...config,
|
|
345
|
+
inlineDiagnostics: {
|
|
346
|
+
...config_1.DEFAULT_IRIS_CONFIG.inlineDiagnostics,
|
|
347
|
+
...(config.inlineDiagnostics ?? {}),
|
|
348
|
+
},
|
|
349
|
+
healthScoreWeights: {
|
|
350
|
+
...config_1.DEFAULT_IRIS_CONFIG.healthScoreWeights,
|
|
351
|
+
...(config.healthScoreWeights ?? {}),
|
|
352
|
+
},
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
//# sourceMappingURL=guards.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":";;AASA,wCAEC;AAiBD,gCAOC;AAED,0CAaC;AAED,4DA2DC;AAsHD,wDAiHC;AAED,0CAaC;AApWD,qCAA0D;AAC1D,0CAA+C;AAC/C,2CAAgD;AAMhD,SAAgB,cAAc,CAAC,QAAgB,EAAE,MAAe;IAC9D,OAAO,IAAA,8BAAkB,EAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;AAC7C,CAAC;AAED,0EAA0E;AAC1E,6EAA6E;AAC7E,iFAAiF;AACjF,MAAM,gBAAgB,GAAG,kHAAkH,CAAA;AAC3I,MAAM,WAAW,GAAG,mDAAmD,CAAA;AAEvE,iFAAiF;AACjF,+EAA+E;AAC/E,4EAA4E;AAC5E,gFAAgF;AAChF,+EAA+E;AAC/E,4DAA4D;AAC5D,MAAM,uBAAuB,GAAG,6DAA6D,CAAA;AAC7F,MAAM,kBAAkB,GAAG,kHAAkH,CAAA;AAE7I,SAAgB,UAAU,CAAC,QAAgB;IACzC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAChD,MAAM,UAAU,GAAG,WAAW,CAAC,WAAW,EAAE,CAAA;IAC5C,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,GAAG,CAAC,GAA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AAE;YACjB,GAAG,4BAAmB,CAAC,iBAAiB;YACxC,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI,EAAE,CAAC;SACpC;QACD,kBAAkB,EAAE;YAClB,GAAG,4BAAmB,CAAC,kBAAkB;YACzC,GAAG,CAAC,MAAM,CAAC,kBAAkB,IAAI,EAAE,CAAC;SACrC;KACF,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * from './types';
|
|
3
|
+
export * from './guards';
|
|
4
|
+
export * from './gate';
|
|
5
|
+
export * from './scoring';
|
|
6
|
+
export * from './suppressions';
|
|
7
|
+
export * from './duplicates';
|
|
8
|
+
export * from './languages';
|
|
9
|
+
export * from './qualitySignals';
|
|
10
|
+
export * from './fileNaming';
|
|
11
|
+
export * from './sfc';
|
|
12
|
+
import { IrisConfig } from './config';
|
|
13
|
+
import { AnalyseBufferResult } from './guards';
|
|
14
|
+
import { CodeSmells, FileAnalysis, FunctionInfo, Language, LanguageAnalysis, TypeScriptMetrics, UnusedImport, Warning } from './types';
|
|
15
|
+
export type { Language, FileAnalysis, FunctionInfo, Warning, TypeScriptMetrics, CodeSmells, UnusedImport, LanguageAnalysis, };
|
|
16
|
+
export interface AnalyseFileOptions {
|
|
17
|
+
relativePath?: string;
|
|
18
|
+
baselineFiles?: ReadonlySet<string>;
|
|
19
|
+
}
|
|
20
|
+
export declare function analyseFile(source: string, config: IrisConfig, filePath?: string, options?: AnalyseFileOptions): FileAnalysis;
|
|
21
|
+
export declare function analyseBuffer(buffer: Uint8Array, config: IrisConfig, filePath?: string, options?: AnalyseFileOptions): AnalyseBufferResult;
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,SAAS,CAAA;AACvB,cAAc,UAAU,CAAA;AACxB,cAAc,QAAQ,CAAA;AACtB,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,kBAAkB,CAAA;AAChC,cAAc,cAAc,CAAA;AAC5B,cAAc,OAAO,CAAA;AAErB,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAMrC,OAAO,EACL,mBAAmB,EAMpB,MAAM,UAAU,CAAA;AAOjB,OAAO,EACL,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,QAAQ,EACR,gBAAgB,EAChB,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACR,MAAM,SAAS,CAAA;AAEhB,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,OAAO,EACP,iBAAiB,EACjB,UAAU,EACV,YAAY,EACZ,gBAAgB,GACjB,CAAA;AAED,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;CACpC;AAMD,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,UAAU,EAClB,QAAQ,SAAe,EACvB,OAAO,GAAE,kBAAuB,GAC/B,YAAY,CAoEd;AAED,wBAAgB,aAAa,CAC3B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,UAAU,EAClB,QAAQ,SAAe,EACvB,OAAO,GAAE,kBAAuB,GAC/B,mBAAmB,CAOrB"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.analyseFile = analyseFile;
|
|
18
|
+
exports.analyseBuffer = analyseBuffer;
|
|
19
|
+
__exportStar(require("./config"), exports);
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
__exportStar(require("./guards"), exports);
|
|
22
|
+
__exportStar(require("./gate"), exports);
|
|
23
|
+
__exportStar(require("./scoring"), exports);
|
|
24
|
+
__exportStar(require("./suppressions"), exports);
|
|
25
|
+
__exportStar(require("./duplicates"), exports);
|
|
26
|
+
__exportStar(require("./languages"), exports);
|
|
27
|
+
__exportStar(require("./qualitySignals"), exports);
|
|
28
|
+
__exportStar(require("./fileNaming"), exports);
|
|
29
|
+
__exportStar(require("./sfc"), exports);
|
|
30
|
+
const analyser_1 = require("./csharp/analyser");
|
|
31
|
+
const analyser_2 = require("./go/analyser");
|
|
32
|
+
const analyser_3 = require("./python/analyser");
|
|
33
|
+
const analyser_4 = require("./ruby/analyser");
|
|
34
|
+
const analyser_5 = require("./ts/analyser");
|
|
35
|
+
const guards_1 = require("./guards");
|
|
36
|
+
const suppressions_1 = require("./suppressions");
|
|
37
|
+
const duplicates_1 = require("./duplicates");
|
|
38
|
+
const languages_1 = require("./languages");
|
|
39
|
+
const scoring_1 = require("./scoring");
|
|
40
|
+
const fileNaming_1 = require("./fileNaming");
|
|
41
|
+
const sfc_1 = require("./sfc");
|
|
42
|
+
function normaliseRelativePath(filePath) {
|
|
43
|
+
return filePath.replace(/\\/g, '/').replace(/^\.\//, '');
|
|
44
|
+
}
|
|
45
|
+
function analyseFile(source, config, filePath = 'unknown.ts', options = {}) {
|
|
46
|
+
// Per-language overrides (Phase 5.10) resolve here, inside core, so every
|
|
47
|
+
// caller - sidebar, workspace scan, CLI, hooks, CI - applies identical
|
|
48
|
+
// thresholds to the same file by construction.
|
|
49
|
+
const prepared = (0, sfc_1.prepareSourceForAnalysis)(source, filePath);
|
|
50
|
+
const resolvedConfig = (0, languages_1.resolveConfigForFile)(filePath, (0, guards_1.normaliseConfig)(config), source);
|
|
51
|
+
const language = prepared.language;
|
|
52
|
+
const analysisPath = prepared.kind === 'source'
|
|
53
|
+
? filePath
|
|
54
|
+
: `${filePath}.${language === 'typescript' ? 'ts' : 'js'}`;
|
|
55
|
+
const parseError = (0, guards_1.detectParseErrorReason)(prepared.source, analysisPath);
|
|
56
|
+
if (parseError) {
|
|
57
|
+
return (0, guards_1.createParseErrorAnalysis)(language, parseError, prepared.source);
|
|
58
|
+
}
|
|
59
|
+
const base = language === 'go' ? (0, analyser_2.analyseGo)(prepared.source, resolvedConfig, filePath)
|
|
60
|
+
: language === 'python' ? (0, analyser_3.analysePython)(prepared.source, resolvedConfig, filePath)
|
|
61
|
+
: language === 'ruby' ? (0, analyser_4.analyseRuby)(prepared.source, resolvedConfig, filePath)
|
|
62
|
+
: language === 'csharp' ? (0, analyser_1.analyseCSharp)(prepared.source, resolvedConfig, filePath)
|
|
63
|
+
: (0, analyser_5.analyseTs)(prepared.source, resolvedConfig, filePath);
|
|
64
|
+
let analysis = { language, suppressed: [], ...base };
|
|
65
|
+
const relativePath = normaliseRelativePath(options.relativePath ?? filePath.split(/[\\/]/).pop() ?? filePath);
|
|
66
|
+
const baselineContainsFile = options.baselineFiles?.has(relativePath) === true;
|
|
67
|
+
const namingPolicy = (0, fileNaming_1.resolveFileNamingPolicy)(relativePath, resolvedConfig.fileNaming);
|
|
68
|
+
const namingScope = namingPolicy?.scope ?? resolvedConfig.fileNamingScope;
|
|
69
|
+
if (namingPolicy && (namingScope === 'all' || !baselineContainsFile)) {
|
|
70
|
+
const finding = (0, fileNaming_1.checkFileNaming)(relativePath, resolvedConfig);
|
|
71
|
+
if (finding) {
|
|
72
|
+
const codeSmells = {
|
|
73
|
+
...analysis.codeSmells,
|
|
74
|
+
fileNamingViolations: [finding],
|
|
75
|
+
};
|
|
76
|
+
analysis = {
|
|
77
|
+
...analysis,
|
|
78
|
+
codeSmells,
|
|
79
|
+
healthScore: (0, scoring_1.computeHealthScore)(analysis.warnings, analysis.typeScriptMetrics, codeSmells, resolvedConfig),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
// Within-file duplicate blocks (Phase 5.9). Cross-file blocks are found by
|
|
84
|
+
// the scan orchestrators over the whole file set, not here.
|
|
85
|
+
if (resolvedConfig.enableDuplicateDetection) {
|
|
86
|
+
const { blocks } = (0, duplicates_1.detectDuplicates)([{ path: filePath, content: source }], resolvedConfig.duplicateBlockMinTokens);
|
|
87
|
+
if (blocks.length > 0) {
|
|
88
|
+
const duplicateBlocks = blocks.flatMap(block => (0, duplicates_1.duplicateBlockToFindings)(block).map(f => f.finding));
|
|
89
|
+
const codeSmells = { ...analysis.codeSmells, duplicateBlocks };
|
|
90
|
+
analysis = {
|
|
91
|
+
...analysis,
|
|
92
|
+
codeSmells,
|
|
93
|
+
healthScore: (0, scoring_1.computeHealthScore)(analysis.warnings, analysis.typeScriptMetrics, codeSmells, resolvedConfig),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// Team-lead override: iris-ignore comments are inert; findings stay live.
|
|
98
|
+
if (resolvedConfig.ignoreSuppressions) {
|
|
99
|
+
return analysis;
|
|
100
|
+
}
|
|
101
|
+
return (0, suppressions_1.applySuppressions)(analysis, (0, suppressions_1.parseSuppressions)(prepared.source), resolvedConfig);
|
|
102
|
+
}
|
|
103
|
+
function analyseBuffer(buffer, config, filePath = 'unknown.ts', options = {}) {
|
|
104
|
+
if ((0, guards_1.looksLikeBinary)(buffer)) {
|
|
105
|
+
return { kind: 'skip', reason: 'binary-file' };
|
|
106
|
+
}
|
|
107
|
+
const source = new TextDecoder('utf-8').decode(buffer);
|
|
108
|
+
return { kind: 'analysis', analysis: analyseFile(source, config, filePath, options) };
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA+DA,kCAyEC;AAED,sCAYC;AAtJD,2CAAwB;AACxB,0CAAuB;AACvB,2CAAwB;AACxB,yCAAsB;AACtB,4CAAyB;AACzB,iDAA8B;AAC9B,+CAA4B;AAC5B,8CAA2B;AAC3B,mDAAgC;AAChC,+CAA4B;AAC5B,wCAAqB;AAGrB,gDAAiD;AACjD,4CAAyC;AACzC,gDAAiD;AACjD,8CAA6C;AAC7C,4CAAyC;AACzC,qCAOiB;AACjB,iDAAqE;AACrE,6CAAyE;AACzE,2CAAkD;AAClD,uCAA8C;AAC9C,6CAAuE;AACvE,+BAAgD;AA4BhD,SAAS,qBAAqB,CAAC,QAAgB;IAC7C,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AAC1D,CAAC;AAED,SAAgB,WAAW,CACzB,MAAc,EACd,MAAkB,EAClB,QAAQ,GAAG,YAAY,EACvB,UAA8B,EAAE;IAEhC,0EAA0E;IAC1E,uEAAuE;IACvE,+CAA+C;IAC/C,MAAM,QAAQ,GAAG,IAAA,8BAAwB,EAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IAC3D,MAAM,cAAc,GAAG,IAAA,gCAAoB,EAAC,QAAQ,EAAE,IAAA,wBAAe,EAAC,MAAM,CAAC,EAAE,MAAM,C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,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;YACpG,MAAM,UAAU,GAAG,EAAE,GAAG,QAAQ,CAAC,UAAU,EAAE,eAAe,EAAE,CAAA;YAC9D,QAAQ,GAAG;gBACT,GAAG,QAAQ;gBACX,UAAU;gBACV,WAAW,EAAE,IAAA,4BAAkB,EAAC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,iBAAiB,EAAE,UAAU,EAAE,cAAc,CAAC;aAC3G,CAAA;QACH,CAAC;IACH,CAAC;IAED,0EAA0E;IAC1E,IAAI,cAAc,CAAC,kBAAkB,EAAE,CAAC;QACtC,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,OAAO,IAAA,gCAAiB,EAAC,QAAQ,EAAE,IAAA,gCAAiB,EAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,cAAc,CAAC,CAAA;AACxF,CAAC;AAED,SAAgB,aAAa,CAC3B,MAAkB,EAClB,MAAkB,EAClB,QAAQ,GAAG,YAAY,EACvB,UAA8B,EAAE;IAEhC,IAAI,IAAA,wBAAe,EAAC,MAAM,CAAC,EAAE,CAAC;QAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,CAAA;IAChD,CAAC;IAED,MAAM,MAAM,GAAG,IAAI,WAAW,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IACtD,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAA;AACvF,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { FileNamingPolicy, HealthScoreWeights, IrisConfig } from './config';
|
|
2
|
+
import type { Language } from './types';
|
|
3
|
+
export interface LanguageRegistryEntry {
|
|
4
|
+
key: Language;
|
|
5
|
+
label: string;
|
|
6
|
+
extensions: string[];
|
|
7
|
+
fileNames?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare const RUBY_SPECIAL_FILENAMES: readonly ["appfile", "berksfile", "brewfile", "capfile", "dangerfile", "deliverfile", "fastfile", "gemfile", "guardfile", "gymfile", "matchfile", "podfile", "pluginfile", "puppetfile", "rakefile", "scanfile", "snapfile", "thorfile", "vagrantfile", ".irbrc", ".pryrc"];
|
|
10
|
+
export declare const LANGUAGE_REGISTRY: readonly LanguageRegistryEntry[];
|
|
11
|
+
export declare const SFC_EXTENSIONS: readonly [".vue", ".svelte"];
|
|
12
|
+
export declare const ANALYSABLE_EXTENSIONS: readonly [...string[], ".vue", ".svelte"];
|
|
13
|
+
export declare const ANALYSABLE_FILENAMES: string[];
|
|
14
|
+
export declare const ANALYSABLE_EXTS: ReadonlySet<string>;
|
|
15
|
+
export declare function fileExtension(filePath: string): string;
|
|
16
|
+
export declare function isAnalysableFile(filePath: string): boolean;
|
|
17
|
+
export declare const LANGUAGE_KEYS: readonly Language[];
|
|
18
|
+
export declare function isLanguageKey(value: string): value is Language;
|
|
19
|
+
export declare function languageLabel(key: Language): string;
|
|
20
|
+
export declare function languageKeyForFile(filePath: string, source?: string): Language;
|
|
21
|
+
export interface LanguageOverride {
|
|
22
|
+
functionLengthThreshold?: number;
|
|
23
|
+
fileLengthThreshold?: number;
|
|
24
|
+
maxFunctionsPerFile?: number;
|
|
25
|
+
maxImportsPerFile?: number;
|
|
26
|
+
maxParameterCount?: number;
|
|
27
|
+
complexityThreshold?: number;
|
|
28
|
+
healthScoreWeights?: Partial<HealthScoreWeights>;
|
|
29
|
+
severityOverrides?: Partial<Record<string, 'error' | 'warning' | 'info'>>;
|
|
30
|
+
gateMaxSmellsPerFile?: number;
|
|
31
|
+
gateMaxSuppressions?: number;
|
|
32
|
+
fileNaming?: FileNamingPolicy;
|
|
33
|
+
}
|
|
34
|
+
export type LanguagesConfig = Partial<Record<Language, LanguageOverride>>;
|
|
35
|
+
export declare const LANGUAGE_OVERRIDE_NUMBER_KEYS: readonly ["functionLengthThreshold", "fileLengthThreshold", "maxFunctionsPerFile", "maxImportsPerFile", "maxParameterCount", "complexityThreshold", "gateMaxSmellsPerFile", "gateMaxSuppressions"];
|
|
36
|
+
export declare const LANGUAGE_OVERRIDE_OBJECT_KEYS: readonly ["healthScoreWeights", "severityOverrides", "fileNaming"];
|
|
37
|
+
export declare const LANGUAGE_OVERRIDE_KEYS: readonly string[];
|
|
38
|
+
export declare function isLanguageOverrideKey(key: string): boolean;
|
|
39
|
+
export declare function resolveLanguageOverride(filePath: string, languages: LanguagesConfig | undefined, source?: string): LanguageOverride | undefined;
|
|
40
|
+
export declare function resolveConfigForFile(filePath: string, base: IrisConfig, source?: string): IrisConfig;
|
|
41
|
+
export interface LanguageGateCaps {
|
|
42
|
+
maxSmellsPerFile?: number;
|
|
43
|
+
maxSuppressions?: number;
|
|
44
|
+
}
|
|
45
|
+
export declare function resolveLanguageGateCaps(filePath: string, languages: LanguagesConfig | undefined, source?: string): LanguageGateCaps | undefined;
|
|
46
|
+
//# sourceMappingURL=languages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"languages.d.ts","sourceRoot":"","sources":["../src/languages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAoB,gBAAgB,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAClG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAQvC,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,QAAQ,CAAA;IACb,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;CACrB;AAED,eAAO,MAAM,sBAAsB,6QAKzB,CAAA;AAEV,eAAO,MAAM,iBAAiB,EAAE,SAAS,qBAAqB,EAYpD,CAAA;AAEV,eAAO,MAAM,cAAc,8BAA+B,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