Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | /**
* Java rule hints — language-specific signals for rules.
*
* `isTestFile` honors both path-based (Maven/Gradle `src/test/java/`,
* generic `/test/`) and filename-based (`*Test.java`, `*Tests.java`,
* `*IT.java`) conventions. Either signal is sufficient.
*
* Throw-syntax: Java's structural error-propagation is `throw new X()`.
* The regex matches the leading `throw` keyword.
*/
import { isTestFile } from './walk.js';
import type { RuleHints } from '@opensip-tools/graph';
const JAVA_SIDE_EFFECT_PRIMITIVES: readonly string[] = [
'System.out.print',
'System.out.println',
'System.out.printf',
'System.err.print',
'System.err.println',
'System.err.printf',
'System.exit',
'System.setProperty',
'System.clearProperty',
'Runtime.exit',
'Runtime.halt',
'Thread.sleep',
'Math.random',
'Files.write',
'Files.delete',
'Files.deleteIfExists',
'Files.createFile',
'Files.createDirectory',
'Files.createDirectories',
];
// Java's structural throw analogue: `throw …` (no `panic!` macro).
// `throw new ExceptionType(...)` is by far the dominant form.
const JAVA_THROW_REGEX = /\bthrow\b/;
const JAVA_GENERATED_FILE_PATTERNS: readonly string[] = [
'**/target/**',
'**/build/**',
'**/out/**',
'**/generated/**',
'**/generated-sources/**',
'**/*$Pb.java',
];
export const javaRuleHints: RuleHints = {
isTestFile,
generatedFilePatterns: JAVA_GENERATED_FILE_PATTERNS,
sideEffectPrimitives: JAVA_SIDE_EFFECT_PRIMITIVES,
throwSyntaxRegex: JAVA_THROW_REGEX,
};
|