From 7f8748650a50db04163835a7215319652c11c737 Mon Sep 17 00:00:00 2001 From: Konrad Weihmann Date: Mon, 25 Apr 2022 16:28:28 +0200 Subject: [PATCH] remove cspell module Relates to #8749 Signed-off-by: Konrad Weihmann --- README.md | 2 - classes/sca-blacklist.bbclass | 1 - classes/sca-cspell.bbclass | 138 ------------------ classes/sca-global.bbclass | 1 - classes/sca-on-recipe.bbclass | 1 - docs/conf/module/cspell.md | 91 ------------ .../code-from-elsewhere/bad-spelling.bb | 2 +- files/module_list.csv | 1 - .../files/fatal | 0 .../files/suppress | 0 .../sca-recipe-cspell-rules-native_1.0.bb | 19 --- .../cspell-native/cspell-native_1.0.bb | 14 -- .../files/cspell.sca.description | 31 ---- .../files/npmaudit.sca.description | 1 - .../cspell-user-dict-native_1.0.bb | 30 ---- .../files/cspell_user.txt | 0 test/lang_metaoe.txt | 1 - 17 files changed, 1 insertion(+), 332 deletions(-) delete mode 100755 classes/sca-cspell.bbclass delete mode 100644 docs/conf/module/cspell.md delete mode 100755 recipes-sca-rules/sca-recipe-cspell-rules-native/files/fatal delete mode 100755 recipes-sca-rules/sca-recipe-cspell-rules-native/files/suppress delete mode 100755 recipes-sca-rules/sca-recipe-cspell-rules-native/sca-recipe-cspell-rules-native_1.0.bb delete mode 100644 recipes-sca/cspell-native/cspell-native_1.0.bb delete mode 100644 recipes-sca/cspell-native/files/cspell.sca.description delete mode 100755 recipes-support/cspell-user-dict-native/cspell-user-dict-native_1.0.bb delete mode 100755 recipes-support/cspell-user-dict-native/files/cspell_user.txt diff --git a/README.md b/README.md index 3dc4277151..3c6bc3c264 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,6 @@ The layer can check on a recipe-level or on an image-level. | configcheck | Check application configurations | | | | x | | | | | | | | | | | | | | | x | | x | | | cppcheck | C/C++ linter | https://github.com/danmar/cppcheck | | | | x | x | x | | | | | | | | | | | | | x | x | x | | cpplint | C/C++ linter | https://github.com/cpplint/cpplint | | | | x | x | x | | | | | | | | | | | | | x | x | x | -| cspell | Spelling linter | https://github.com/Jason3S/cspell | meta-oe, manual enable | x | | x | | | | | | | | | | x | | | | | | | x | | cvecheck | Check for unpatched CVEs | https://github.com/clearlinux/cve-check-tool | manual enable | x | | x | | | | | | | | | | | | | x | | x | | | | darglint | Python docstring linter | https://github.com/terrencepreilly/darglint | | | | x | | | x | | | | | | | | | | | | | | x | | dennis | I18N linter | https://github.com/willkg/dennis/ | | | | x | | | | | | | | | | | | | | x | | x | x | @@ -292,7 +291,6 @@ each tool does have it's own benefits and flaws so don't be mad if you have 10k+ - [configcheck](docs/conf/module/configcheck.md) - [cppcheck](docs/conf/module/cppcheck.md) - [cpplint](docs/conf/module/cpplint.md) - - [cspell](docs/conf/module/cspell.md) - [cvecheck](docs/conf/module/cvecheck.md) - [darglint](docs/conf/module/darglint.md) - [dennis](docs/conf/module/dennis.md) diff --git a/classes/sca-blacklist.bbclass b/classes/sca-blacklist.bbclass index 315506bb58..0389bb5e25 100644 --- a/classes/sca-blacklist.bbclass +++ b/classes/sca-blacklist.bbclass @@ -13,7 +13,6 @@ SCA_BLACKLIST_cmake ?= "" SCA_BLACKLIST_configcheck ?= "" SCA_BLACKLIST_cppcheck ?= "linux-.*" SCA_BLACKLIST_cpplint ?= "linux-.*" -SCA_BLACKLIST_cspell ?= "linux-.*" SCA_BLACKLIST_cvecheck ?= "" SCA_BLACKLIST_darglint ?= "" SCA_BLACKLIST_dennis ?= "linux-.*" diff --git a/classes/sca-cspell.bbclass b/classes/sca-cspell.bbclass deleted file mode 100755 index d31ec99cb0..0000000000 --- a/classes/sca-cspell.bbclass +++ /dev/null @@ -1,138 +0,0 @@ -## SPDX-License-Identifier: BSD-2-Clause -## Copyright (c) 2019, Konrad Weihmann - -SCA_CSPELL_CHECK_LANG ?= "CPP HTML PYTHON TXT" - -## Lang spec implementation -SCA_CSPELL_LANG_CPP_files ?= ".c .cpp .h .hpp" -SCA_CSPELL_LANG_HTML_files ?= ".html .htm .js" -SCA_CSPELL_LANG_PYTHON_files ?= ".py" -SCA_CSPELL_LANG_PYTHON_shebang ?= "${SCA_PYTHON_SHEBANG}" -SCA_CSPELL_LANG_TXT_files ?= ".txt .md .rst" - -SCA_RAW_RESULT_FILE[cspell] = "txt" - -inherit sca-conv-to-export -inherit sca-datamodel -inherit sca-global -inherit sca-helper -inherit sca-license-filter -inherit sca-suppress -inherit sca-image-backtrack -inherit sca-tracefiles - -def write_config(_base, _extra_dicts, _target): - import os - import json - import copy - obj = copy.deepcopy(_base) - for k, v in _extra_dicts.items(): - obj["dictionaries"].append(k) - obj["dictionaryDefinitions"].append(v) - with open(_target, "w") as o: - json.dump(obj, o) - -def do_sca_conv_cspell(d): - import os - import re - - package_name = d.getVar("PN") - buildpath = d.getVar("SCA_SOURCES_DIR") - - items = [] - pattern = r"^(?P.*)\:(?P\d+):(?P\d+)\s+-\s+(?P.*)\s+\((?P.*)\)" - _suppress = sca_suppress_init(d, "", None) - _findings = [] - - if os.path.exists(sca_raw_result_file(d, "cspell")): - with open(sca_raw_result_file(d, "cspell"), "r") as f: - for m in re.finditer(pattern, f.read(), re.MULTILINE): - try: - g = sca_get_model_class(d, - PackageName=package_name, - Tool="cspell", - BuildPath=buildpath, - File=m.group("file"), - Column=m.group("column"), - Line=m.group("line"), - Message=m.group("msg"), - ID=m.group("id").replace(" ", "-"), - Severity="info") - if _suppress.Suppressed(g): - continue - if g.Scope not in clean_split(d, "SCA_SCOPE_FILTER"): - continue - if g.Severity in sca_allowed_warning_level(d): - _findings += sca_backtrack_findings(d, g) - except Exception as e: - sca_log_note(d, str(e)) - - sca_add_model_class_list(d, _findings) - return sca_save_model_to_string(d) - -def sca_get_cspell_available_dicts(d): - import glob - _res = {} - for item in glob.glob(d.expand("${STAGING_LIBDIR_NATIVE}/node_modules/**/*.gz"), recursive=True): - if not "cspell" in item: - continue - _name = os.path.basename(item).split(".")[0] - _res[_name] = { "name": _name, "path": item} - return _res - -python do_sca_cspell() { - import os - import subprocess - import json - - _config = { - "version": "0.1", - "language": "en", - "ignorePaths": [], - "maxNumberOfProblems": 1000000, - "dictionaries": ["user"], - "dictionaryDefinitions": [ - { "name": "user", "path": "{}/cspell-user/cspell_user.txt".format(d.getVar("STAGING_DATADIR_NATIVE"))} - ] - } - - _lang_configs = sca_get_cspell_available_dicts(d) - - _config_file = os.path.join(d.getVar("T"), "cspell.json") - - _args = ["cspell"] - _args += ["-c", _config_file] - _args += ["--no-color"] - - cmd_output = "" - ## Get all vars - for k in clean_split(d, "SCA_CSPELL_CHECK_LANG"): - _files = d.getVar("{}{}_files".format("SCA_CSPELL_LANG_", k)) or "" - _shebang = d.getVar("{}{}_shebang".format("SCA_CSPELL_LANG_", k)) or ".*" - _check_files = get_files_by_extention_or_shebang(d, d.getVar("SCA_SOURCES_DIR"), _shebang, _files, - sca_filter_files(d, d.getVar("SCA_SOURCES_DIR"), clean_split(d, "SCA_FILE_FILTER_EXTRA"))) - if any(_check_files): - write_config(_config, _lang_configs, _config_file) - cmd_output += exec_wrap_check_output(d, _args, _check_files) - - with open(sca_raw_result_file(d, "cspell"), "w") as o: - o.write(cmd_output) -} - -python do_sca_cspell_report() { - import os - ## Create data model - d.setVar("SCA_DATAMODEL_STORAGE", "{}/cspell.dm".format(d.getVar("T"))) - dm_output = do_sca_conv_cspell(d) - with open(d.getVar("SCA_DATAMODEL_STORAGE"), "w") as o: - o.write(dm_output) - - sca_task_aftermath(d, "cspell") -} - -do_sca_cspell[doc] = "Lint test files with cspell" -do_sca_cspell_report[doc] = "Report findings of do_sca_cspell" -addtask do_sca_cspell after do_compile before do_sca_tracefiles -addtask do_sca_cspell_report after do_sca_tracefiles before do_sca_deploy - -DEPENDS += "cspell-native sca-recipe-cspell-rules-native cspell-user-dict-native" diff --git a/classes/sca-global.bbclass b/classes/sca-global.bbclass index d7d781fc74..6cdde88e38 100644 --- a/classes/sca-global.bbclass +++ b/classes/sca-global.bbclass @@ -150,7 +150,6 @@ SCA_AVAILABLE_MODULES ?= "\ yara \ " # additional layer requirements -SCA_AVAILABLE_MODULES[cspell] = "openembedded-layer" SCA_AVAILABLE_MODULES[eslint] = "openembedded-layer" SCA_AVAILABLE_MODULES[htmlhint] = "openembedded-layer" SCA_AVAILABLE_MODULES[inspec] = "openembedded-layer rubygems" diff --git a/classes/sca-on-recipe.bbclass b/classes/sca-on-recipe.bbclass index 8e99653717..9348971460 100755 --- a/classes/sca-on-recipe.bbclass +++ b/classes/sca-on-recipe.bbclass @@ -19,7 +19,6 @@ SCA_ENABLED_MODULES_RECIPE ?= "\ cmake \ cppcheck \ cpplint \ - cspell \ cvecheck \ darglint \ dennis \ diff --git a/docs/conf/module/cspell.md b/docs/conf/module/cspell.md deleted file mode 100644 index 9560c20109..0000000000 --- a/docs/conf/module/cspell.md +++ /dev/null @@ -1,91 +0,0 @@ -# Configuration for cspell - -This module is someway different in configuration. -First of all this module does not support suppression or fatal-errors, as the only thing, this module -produces is to warn you about typos and unknown words. -The check itself is done for each configured language - meaning a defined set of dictionaries is used for checking. - -## Supported environments/languages - -* spelling - -## Configuration - -| var | purpose | type | default | -| ------------- |:-------------:| -----:| -----: -| SCA_BLACKLIST_cspell | Blacklist filter for this tool | space-separated-list | "linux-*" -| SCA_CSPELL_CHECK_LANG | List of languages configured | space-separated-list | "CPP HTML PYTHON TXT" -| SCA_CSPELL_LANG_CPP_files | Files to check for CPP | space-separated-list | ".c .cpp .h .hpp" -| SCA_CSPELL_LANG_HTML_files | Files to check for HTML | space-separated-list | ".html .htm .js" -| SCA_CSPELL_LANG_PYTHON_files | Files to check for PYTHON | space-separated-list | ".py" -| SCA_CSPELL_LANG_PYTHON_shebang | Files to check for PYTHON | space-separated-list | ".*python" -| SCA_CSPELL_LANG_TXT_files | Files to check for TXT | space-separated-list | ".txt .md .rst" - -## Add custom words to supported dictionaries - -To add a custom word to the dictionary -create a recipe called **cspell-user-dict-native_%.bbappend** in your layer -In this recipe insert the following function - -```bitbake -do_compile:append() { - echo "" >> "${WORKDIR}/spell_user.txt" -} -``` - -## Supports - -* [ ] suppression of IDs -* [ ] terminate build on fatal -* [x] run on recipe -* [ ] run on image -* [ ] run with SCA-layer default settings (see SCA_AVAILABLE_MODULES) - -## Requires - -* [ ] requires online access - -## Detailed configuration - -* **SCA_CSPELL_LANG_\_files** - List of file extensions to check -* **SCA_CSPELL_LANG_\_shebang** - Regular expression for getting file by shebang - -## Notes - -By the default this module does only generate warnings of level **"info"**. -So if you like them to be deployed you have to set **SCA_WARNING_LEVEL** to __"info"__ globally or in the recipe. - -## Known error-IDs - -__tbd__ - -## Checking scope - -* [ ] security -* [ ] functional defects -* [ ] compliance -* [x] style issues - -## Statistics - -* ⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜ 04/10 Build Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬜⬜ 08/10 Execution Speed -* ⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜ 04/10 Quality - -## Score mapping - -### Error considered as security relevant - -* n.a. - -### Error considered as functional defect - -* n.a. - -### Error consired as compliance issue - -* n.a. - -### Error considered as style issue - -* cspell.cspell.* diff --git a/dynamic-distro/scatest/code-from-elsewhere/bad-spelling.bb b/dynamic-distro/scatest/code-from-elsewhere/bad-spelling.bb index 3657bc3884..bdc2c52b38 100644 --- a/dynamic-distro/scatest/code-from-elsewhere/bad-spelling.bb +++ b/dynamic-distro/scatest/code-from-elsewhere/bad-spelling.bb @@ -15,4 +15,4 @@ inherit sca SCA_SEVERITY_TRANSFORM_EXTRA += "cspell.*=warning" -SCA_ENABLED_MODULES = "bitbake cspell" +SCA_ENABLED_MODULES = "bitbake" diff --git a/files/module_list.csv b/files/module_list.csv index 69888271d0..68b96c61e4 100644 --- a/files/module_list.csv +++ b/files/module_list.csv @@ -10,7 +10,6 @@ cmake,Cmake compiler issues,,,,,x,x,x,,,,,,,,,,,,,,x, configcheck,Check application configurations,,,,x,,,,,,,,,,,,,,,x,,x, cppcheck,C/C++ linter,https://github.com/danmar/cppcheck,,,,x,x,x,,,,,,,,,,,,,x,x,x cpplint,C/C++ linter,https://github.com/cpplint/cpplint,,,,x,x,x,,,,,,,,,,,,,x,x,x -cspell,Spelling linter,https://github.com/Jason3S/cspell,"meta-oe, manual enable",x,,x,,,,,,,,,,x,,,,,,,x cvecheck,Check for unpatched CVEs,https://github.com/clearlinux/cve-check-tool,manual enable,x,,x,,,,,,,,,,,,,x,,x,, darglint,Python docstring linter,https://github.com/terrencepreilly/darglint,,,,x,,,x,,,,,,,,,,,,,,x dennis,I18N linter,https://github.com/willkg/dennis/,,,,x,,,,,,,,,,,,,,x,,x,x diff --git a/recipes-sca-rules/sca-recipe-cspell-rules-native/files/fatal b/recipes-sca-rules/sca-recipe-cspell-rules-native/files/fatal deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-cspell-rules-native/files/suppress b/recipes-sca-rules/sca-recipe-cspell-rules-native/files/suppress deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-cspell-rules-native/sca-recipe-cspell-rules-native_1.0.bb b/recipes-sca-rules/sca-recipe-cspell-rules-native/sca-recipe-cspell-rules-native_1.0.bb deleted file mode 100755 index 7b5a132152..0000000000 --- a/recipes-sca-rules/sca-recipe-cspell-rules-native/sca-recipe-cspell-rules-native_1.0.bb +++ /dev/null @@ -1,19 +0,0 @@ -SUMMARY = "SCA ruleset for cspell at recipes" -DESCRIPTION = "Rules to configure how cspell is affecting the build" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "BSD-2-Clause" -LIC_FILES_CHKSUM = "file://${SCA_LAYERDIR}/LICENSE;md5=a4a2bbea1db029f21b3a328c7a059172" - -SRC_URI = "file://suppress \ - file://fatal" - -inherit native - -do_install() { - install -d "${D}${datadir}" - install "${WORKDIR}/suppress" "${D}${datadir}/cspell-recipe-suppress" - install "${WORKDIR}/fatal" "${D}${datadir}/cspell-recipe-fatal" -} - -FILES:${PN} = "${datadir}" diff --git a/recipes-sca/cspell-native/cspell-native_1.0.bb b/recipes-sca/cspell-native/cspell-native_1.0.bb deleted file mode 100644 index 75c9404005..0000000000 --- a/recipes-sca/cspell-native/cspell-native_1.0.bb +++ /dev/null @@ -1,14 +0,0 @@ -SUMMARY = "sca definition for cspell" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "BSD-2-Clause" -LIC_FILES_CHKSUM = "file://${SCA_LAYERDIR}/LICENSE;md5=a4a2bbea1db029f21b3a328c7a059172" - -DEPENDS += "npm-cspell-native" - -inherit sca-description -inherit native - -SCA_TOOL_DESCRIPTION = "cspell" - -do_compile[noexec] = "1" diff --git a/recipes-sca/cspell-native/files/cspell.sca.description b/recipes-sca/cspell-native/files/cspell.sca.description deleted file mode 100644 index e03d1787de..0000000000 --- a/recipes-sca/cspell-native/files/cspell.sca.description +++ /dev/null @@ -1,31 +0,0 @@ -{ - "buildspeed": 4, - "execspeed": 8, - "languages": [ - "spelling" - ], - "uses": [ - "@npm" - ], - "online": true, - "quality": 4, - "scope": [ - "style" - ], - "score": { - "style": [ - "cspell.cspell..*" - ] - }, - "test": { - "integration": [ - {"cmd": ["cspell", "--help"], "returncode": 1} - ], - "no-findings": [ - "bad-bitbake" - ], - "findings": [ - "bad-spelling" - ] - } -} \ No newline at end of file diff --git a/recipes-sca/npmaudit-sca-native/files/npmaudit.sca.description b/recipes-sca/npmaudit-sca-native/files/npmaudit.sca.description index dc6fe825d6..3a0bc5991e 100644 --- a/recipes-sca/npmaudit-sca-native/files/npmaudit.sca.description +++ b/recipes-sca/npmaudit-sca-native/files/npmaudit.sca.description @@ -22,7 +22,6 @@ {"cmd": ["npm", "audit", "--help"], "returncode": 0} ], "findings": [ - "cspell" ], "no-findings": [ "busybox" diff --git a/recipes-support/cspell-user-dict-native/cspell-user-dict-native_1.0.bb b/recipes-support/cspell-user-dict-native/cspell-user-dict-native_1.0.bb deleted file mode 100755 index ba496cd5d1..0000000000 --- a/recipes-support/cspell-user-dict-native/cspell-user-dict-native_1.0.bb +++ /dev/null @@ -1,30 +0,0 @@ -SUMMARY = "User definied dictionary for cspell" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "BSD-2-Clause" -LIC_FILES_CHKSUM = "file://${SCA_LAYERDIR}/LICENSE;md5=a4a2bbea1db029f21b3a328c7a059172" - -SRC_URI = "file://cspell_user.txt" - -inherit native - -do_compile() { - : -} - -# To add a custom word to the dictionary -# create a recipe called 'cspell-user-dict-native_%.bbappend' in your layer -# -# In this recipe insert the following function -# -# do_compile:append() { -# echo "" >> "${WORKDIR}/cspell_user.txt" -# } -# - -do_install() { - install -d "${D}${datadir}/cspell-user/" - install "${WORKDIR}/cspell_user.txt" "${D}${datadir}/cspell-user/" -} - -FILES:${PN} = "${datadir}" diff --git a/recipes-support/cspell-user-dict-native/files/cspell_user.txt b/recipes-support/cspell-user-dict-native/files/cspell_user.txt deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/test/lang_metaoe.txt b/test/lang_metaoe.txt index 37d3c68979..b4a30ae2cb 100644 --- a/test/lang_metaoe.txt +++ b/test/lang_metaoe.txt @@ -1,4 +1,3 @@ -cspell eslint htmlhint jshint