use crate::languages::spec::{
DEFAULT_TOOL_TIMEOUT_SECS, DiagnosticsStream, LanguageSupport, OutputFormat, ToolSpec,
};
pub static CPPCHECK: ToolSpec = ToolSpec {
name: "cppcheck",
command: &[
"cppcheck",
"--output-format=sarif",
"--enable=warning,style",
"--error-exitcode=2",
],
local_paths: &[],
config_files: &[
"CMakeLists.txt",
"Makefile",
"meson.build",
"compile_commands.json",
],
config_flag: None,
output_format: OutputFormat::Sarif,
diagnostics_stream: DiagnosticsStream::Stderr,
timeout_secs: DEFAULT_TOOL_TIMEOUT_SECS,
timeout_context: None,
establishes_compilation: false,
serial_in_repository: false,
accepts_files: true,
};
pub static DOTNET_FORMAT: ToolSpec = ToolSpec {
name: "dotnet format",
command: &["dotnet", "format", "--verify-no-changes", "--no-restore"],
local_paths: &[],
config_files: &["*.sln", "*.csproj"],
config_flag: None,
output_format: OutputFormat::Msbuild,
diagnostics_stream: DiagnosticsStream::Stdout,
timeout_secs: 600,
timeout_context: Some(", including its MSBuild project load"),
establishes_compilation: false,
serial_in_repository: false,
accepts_files: false,
};
pub static C: LanguageSupport = LanguageSupport {
name: "c",
display_name: "C",
extensions: &[".c", ".h"],
filenames: &[],
filename_prefixes: &[],
tools: &[&CPPCHECK],
conventions: &[
"Buffer overruns and off-by-one indexing into fixed arrays",
"Use-after-free, double free, and leaks on early error paths",
"Unchecked return values from allocation and system calls",
"Signedness confusion and integer overflow in arithmetic",
"Data races on shared state without synchronisation",
],
vendored_dirs: &[],
};
pub static CPP: LanguageSupport = LanguageSupport {
name: "cpp",
display_name: "C++",
extensions: &[".cpp", ".hpp", ".cc", ".hh", ".cxx", ".hxx"],
filenames: &[],
filename_prefixes: &[],
tools: &[&CPPCHECK],
conventions: &[
"Dangling references and iterators into reallocated containers",
"Ownership confusion between raw and smart pointers",
"Missing virtual destructors on polymorphic base classes",
"Uninitialised members and reads from moved-from state",
"Templates instantiated with types that do not satisfy their assumptions",
],
vendored_dirs: &[],
};
pub static CSHARP: LanguageSupport = LanguageSupport {
name: "csharp",
display_name: "C#",
extensions: &[".cs"],
filenames: &[],
filename_prefixes: &[],
tools: &[&DOTNET_FORMAT],
conventions: &[
"async void, and tasks that are never awaited",
"IDisposable not disposed on every path",
"Null dereferences the nullable flow analysis would catch",
"Closures capturing a loop variable's stale value",
"Struct copies where a reference was intended",
],
vendored_dirs: &[],
};
pub(crate) static FAMILY: &[&LanguageSupport] = &[&C, &CPP, &CSHARP];