drep/languages/definitions/
jvm.rs1use crate::languages::spec::{
4 DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
5};
6
7static JVM_VENDORED_DIRS: &[&str] = &["build", ".gradle", "target"];
19
20pub static CHECKSTYLE: ToolSpec = ToolSpec {
27 name: "checkstyle",
28 command: &["checkstyle", "-f", "sarif"],
29 local_paths: &[],
30 config_files: &[
31 "checkstyle.xml",
32 ".checkstyle.xml",
33 "config/checkstyle/checkstyle.xml",
34 "gradle/config/checkstyle/checkstyle.xml",
35 ],
36 config_flag: Some("-c"),
37 output_format: OutputFormat::Sarif,
38 diagnostics_stream: DiagnosticsStream::Stdout,
39 timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
42 timeout_context: None,
43 establishes_compilation: false,
46 serial_in_repository: false,
47 accepts_files: true,
48};
49
50pub static KTLINT: ToolSpec = ToolSpec {
56 name: "ktlint",
57 command: &["ktlint", "--log-level=none", "--reporter=json"],
58 local_paths: &[],
59 config_files: &[".editorconfig"],
62 config_flag: None,
63 output_format: OutputFormat::Ktlint,
64 diagnostics_stream: DiagnosticsStream::Stdout,
65 timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
66 timeout_context: None,
67 establishes_compilation: false,
68 serial_in_repository: false,
69 accepts_files: true,
70};
71
72pub static JAVA: LanguageSupport = LanguageSupport {
74 name: "java",
75 display_name: "Java",
76 extensions: &[".java"],
77 filenames: &[],
78 filename_prefixes: &[],
79 tools: &[&CHECKSTYLE],
80 conventions: &[
81 "Resources closed on every path, and try-with-resources where it applies",
82 "Null handling: Optional versus a nullable return, and unchecked dereferences",
83 "equals/hashCode/compareTo consistency, and mutable state in a shared object",
84 "Exceptions swallowed or logged and rethrown, losing the original cause",
85 "Concurrency: unsynchronised shared state, and non-thread-safe fields on a singleton",
86 ],
87 vendored_dirs: JVM_VENDORED_DIRS,
88};
89
90pub static KOTLIN: LanguageSupport = LanguageSupport {
95 name: "kotlin",
96 display_name: "Kotlin",
97 extensions: &[".kt", ".kts"],
98 filenames: &[],
99 filename_prefixes: &[],
100 tools: &[&KTLINT],
101 conventions: &[
102 "Platform types from Java interop dereferenced without a null check",
103 "runBlocking on a coroutine path, and scopes that outlive their work",
104 "!! where the null case is real, and lateinit read before assignment",
105 "data class equality over mutable properties",
106 ],
107 vendored_dirs: JVM_VENDORED_DIRS,
108};
109
110pub static SCALA: LanguageSupport = LanguageSupport {
117 name: "scala",
118 display_name: "Scala",
119 extensions: &[".scala", ".sc"],
120 filenames: &[],
121 filename_prefixes: &[],
122 tools: &[],
123 conventions: &[
124 "Partial functions and non-exhaustive matches",
125 "Option/Either handling versus get and head on an empty collection",
126 "Implicits whose resolution is not obvious at the call site",
127 "Futures without an explicit ExecutionContext, and blocking inside one",
128 ],
129 vendored_dirs: JVM_VENDORED_DIRS,
130};
131
132pub static GROOVY: LanguageSupport = LanguageSupport {
138 name: "groovy",
139 display_name: "Groovy",
140 extensions: &[".groovy", ".gradle"],
141 filenames: &[],
142 filename_prefixes: &[],
143 tools: &[],
144 conventions: &[
145 "Dynamic dispatch where a typed call would fail at compile time",
146 "Gradle configuration-time work that belongs in a task action",
147 "Dependency and plugin versions pinned versus floating",
148 "String interpolation of values that should be escaped",
149 ],
150 vendored_dirs: JVM_VENDORED_DIRS,
151};
152
153pub(crate) static FAMILY: &[&LanguageSupport] = &[&JAVA, &KOTLIN, &SCALA, &GROOVY];