@codacy/tools-cppcheck-2 0.6.1 → 0.8.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.
Files changed (2) hide show
  1. package/dist/index.js +23 -0
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -3853,6 +3853,25 @@ function ruleMetadata(errorId) {
3853
3853
  return PATTERN_META.get(patternId) ?? { category: "ErrorProne", severity: "Info" };
3854
3854
  }
3855
3855
  var BLACKLISTED_ERROR_IDS = /* @__PURE__ */ new Set(["unusedFunction", "missingIncludeSystem", "checkersReport"]);
3856
+ var ADDON_PREFIX_MAP = /* @__PURE__ */ new Map([
3857
+ ["misra", "misra"],
3858
+ ["threadsafety", "threadsafety"],
3859
+ ["y2038", "y2038"]
3860
+ ]);
3861
+ function requiredAddons(patterns) {
3862
+ if (patterns.length === 0) return new Set(ADDON_PREFIX_MAP.values());
3863
+ const addons = /* @__PURE__ */ new Set();
3864
+ for (const p of patterns) {
3865
+ if (!p.patternId.startsWith(`${TOOL_ID}_`)) continue;
3866
+ const ruleId = p.patternId.slice(TOOL_ID.length + 1);
3867
+ const dashIdx = ruleId.indexOf("-");
3868
+ if (dashIdx === -1) continue;
3869
+ const prefix = ruleId.slice(0, dashIdx);
3870
+ const addon = ADDON_PREFIX_MAP.get(prefix);
3871
+ if (addon) addons.add(addon);
3872
+ }
3873
+ return addons;
3874
+ }
3856
3875
  var BINARY = "cppcheck";
3857
3876
  var xmlParser = new import_fast_xml_parser.XMLParser({
3858
3877
  ignoreAttributes: false,
@@ -3883,6 +3902,7 @@ async function resolveBinaryPath(ctx) {
3883
3902
  }
3884
3903
  var adapter = {
3885
3904
  ...descriptor,
3905
+ patternsMetadata: patterns_default,
3886
3906
  compatibleVersions: ">=2.0.0",
3887
3907
  website: "https://cppcheck.sourceforge.io",
3888
3908
  prerequisites: [],
@@ -4016,6 +4036,9 @@ var adapter = {
4016
4036
  if (codacyConfig.useLocalConfigurationFile && codacyConfig.localConfigurationFile) {
4017
4037
  args.push(`--suppressions-list=${codacyConfig.localConfigurationFile}`);
4018
4038
  }
4039
+ for (const addon of requiredAddons(codacyConfig.patterns)) {
4040
+ args.push(`--addon=${addon}`);
4041
+ }
4019
4042
  args.push(...absoluteFiles);
4020
4043
  try {
4021
4044
  const { stderr, exitCode } = await (0, import_tooling.spawnTool)(binary, args, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codacy/tools-cppcheck-2",
3
- "version": "0.6.1",
3
+ "version": "0.8.0",
4
4
  "description": "Cppcheck adapter — CLI-mode C/C++ static analyzer",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,7 +9,7 @@
9
9
  ],
10
10
  "dependencies": {
11
11
  "fast-xml-parser": "^5.5.6",
12
- "@codacy/tooling": "0.6.1"
12
+ "@codacy/tooling": "0.8.0"
13
13
  },
14
14
  "license": "MIT",
15
15
  "author": "Codacy <support@codacy.com> (https://www.codacy.com)",