diff --git a/README.md b/README.md index 6fb55b900a..632c4f39e9 100644 --- a/README.md +++ b/README.md @@ -214,7 +214,6 @@ The layer can check on a recipe-level or on an image-level. | oelint | Bitbake recipe linter | https://github.com/priv-kweihmann/oelint-adv | | | x | x | | | | | | | | | | | | | | x | | | x | | perl | Perl warnings check | | | | | x | | | | | | | | | | | | | | x | | x | | | perlcritic | Perl linter | https://metacpan.org/pod/perlcritic | | | | x | | | | | | | | | | | | | | x | | x | | -| phpstan | PHP linter | https://github.com/phpstan/phpstan | meta-oe, manual enable | x | | x | | | | | | x | | | | | | | | | | | x | | pkgqaenc | Enhanced package QA | | | | | x | | | | | | | | | | | | | x | | x | | | | proselint | Spelling and text linter | https://github.com/amperser/proselint/ | | | x | x | | | | | | | | | | x | | | | | | | x | | protolint | Lint protobuf files | https://github.com/yoheimuta/protolint | | | | x | | | | | | | | | | x | | | | x | | | x | @@ -309,7 +308,6 @@ each tool does have it's own benefits and flaws so don't be mad if you have 10k+ - [oelint](docs/conf/module/oelint.md) - [perl](docs/conf/module/perl.md) - [perlcritic](docs/conf/module/perlcritic.md) - - [phpstan](docs/conf/module/phpstan.md) - [pkgqaenc](docs/conf/module/pkgqaenc.md) - [proselint](docs/conf/module/proselint.md) - [protolint](docs/conf/module/protolint.md) diff --git a/classes/sca-blacklist.bbclass b/classes/sca-blacklist.bbclass index 208a99cf71..bc07a539e9 100644 --- a/classes/sca-blacklist.bbclass +++ b/classes/sca-blacklist.bbclass @@ -40,7 +40,6 @@ SCA_BLACKLIST_mypy ?= "linux-.*" SCA_BLACKLIST_nixauditor ?= "" SCA_BLACKLIST_oclint ?= "linux-.*" SCA_BLACKLIST_oelint ?= "" -SCA_BLACKLIST_phpstan ?= "" SCA_BLACKLIST_proselint ?= "" SCA_BLACKLIST_protolint ?= "" SCA_BLACKLIST_perl ?= "" diff --git a/classes/sca-global.bbclass b/classes/sca-global.bbclass index 5017513b23..6f523237b3 100644 --- a/classes/sca-global.bbclass +++ b/classes/sca-global.bbclass @@ -151,7 +151,6 @@ SCA_AVAILABLE_MODULES ?= "\ " # additional layer requirements SCA_AVAILABLE_MODULES[inspec] = "openembedded-layer rubygems" -SCA_AVAILABLE_MODULES[phpstan] = "openembedded-layer" SCA_AVAILABLE_MODULES[pyright] = "openembedded-layer" SCA_AVAILABLE_MODULES[reek] = "rubygems" SCA_AVAILABLE_MODULES[retire] = "openembedded-layer" diff --git a/classes/sca-on-recipe.bbclass b/classes/sca-on-recipe.bbclass index e9df31e8b7..e390274ed8 100755 --- a/classes/sca-on-recipe.bbclass +++ b/classes/sca-on-recipe.bbclass @@ -43,7 +43,6 @@ SCA_ENABLED_MODULES_RECIPE ?= "\ oelint \ perl \ perlcritic \ - phpstan \ pkgqaenc \ proselint \ protolint \ diff --git a/classes/sca-phpstan.bbclass b/classes/sca-phpstan.bbclass deleted file mode 100755 index 7a83a50dd9..0000000000 --- a/classes/sca-phpstan.bbclass +++ /dev/null @@ -1,108 +0,0 @@ -## SPDX-License-Identifier: BSD-2-Clause -## Copyright (c) 2019, Konrad Weihmann - -## Add ids to suppress on a recipe level -SCA_PHPSTAN_EXTRA_SUPPRESS ?= "" -## Add ids to lead to a fatal on a recipe level -SCA_PHPSTAN_EXTRA_FATAL ?= "" -SCA_PHPSTAN_FILE_FILTER ?= ".php" - -SCA_RAW_RESULT_FILE[phpstan] = "json" - -inherit sca-conv-to-export -inherit sca-datamodel -inherit sca-global -inherit sca-helper -inherit sca-suppress -inherit sca-image-backtrack -inherit sca-tracefiles - -def do_sca_conv_phpstan(d): - import os - import json - import hashlib - - package_name = d.getVar("PN") - buildpath = d.getVar("SCA_SOURCES_DIR") - - _findings = [] - _suppress = sca_suppress_init(d, "SCA_PHPSTAN_EXTRA_SUPPRESS", - d.expand("${STAGING_DATADIR_NATIVE}/phpstan-${SCA_MODE}-suppress")) - - _severity_map = { - "True": "warning", - "False": "error" - } - - if os.path.exists(sca_raw_result_file(d, "phpstan")): - content = [] - with open(sca_raw_result_file(d, "phpstan"), "r") as f: - try: - content = json.load(f) - except json.JSONDecodeError: - content = {"files": {}} - for k,v in content["files"].items(): - for m in v["messages"]: - try: - g = sca_get_model_class(d, - PackageName=package_name, - BuildPath=buildpath, - Tool="phpstan", - File=k, - Line=str(m["line"] or 1), - Message=m["message"], - ID=hashlib.md5(str.encode(m["message"])).hexdigest(), - Severity=_severity_map[str(m["ignorable"])]) - 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 exp: - sca_log_note(d, str(exp)) - - sca_add_model_class_list(d, _findings) - return sca_save_model_to_string(d) - -python do_sca_phpstan() { - import os - import subprocess - - ## Run - _args = [os.path.join(d.getVar("STAGING_BINDIR_NATIVE"), "phpstan/vendor/bin/phpstan")] - _args += ["analyse"] - _args += ["--ansi"] - _args += ["-n"] - _args += ["--error-format=json"] - _args += ["--no-progress"] - - _files = get_files_by_extention_or_shebang(d, d.getVar("SCA_SOURCES_DIR"), ".*php", [".php"], \ - sca_filter_files(d, d.getVar("SCA_SOURCES_DIR"), clean_split(d, "SCA_FILE_FILTER_EXTRA"))) - - cmd_output = exec_wrap_check_output(d, _args, _files, combine=exec_wrap_combine_json_subdict, key="files", - default_val={"files": {}}) - - with open(sca_raw_result_file(d, "phpstan"), "w") as o: - o.write(cmd_output) -} -do_sca_phpstan[network] = "1" - -python do_sca_phpstan_report() { - import os - ## Create data model - d.setVar("SCA_DATAMODEL_STORAGE", "{}/phpstan.dm".format(d.getVar("T"))) - dm_output = do_sca_conv_phpstan(d) - with open(d.getVar("SCA_DATAMODEL_STORAGE"), "w") as o: - o.write(dm_output) - - sca_task_aftermath(d, "phpstan", get_fatal_entries(d, "SCA_PHPSTAN_EXTRA_FATAL", - d.expand("${STAGING_DATADIR_NATIVE}/phpstan-${SCA_MODE}-fatal"))) -} - -do_sca_phpstan[doc] = "Lint php scripts with phpstan in workspace" -do_sca_phpstan_report[doc] = "Report findings of do_sca_phpstan" -addtask do_sca_phpstan after do_configure before do_sca_tracefiles -addtask do_sca_phpstan_report after do_sca_tracefiles before do_sca_deploy - -DEPENDS += "phpstan-native sca-recipe-phpstan-rules-native" diff --git a/docs/conf/module/phpstan.md b/docs/conf/module/phpstan.md deleted file mode 100644 index 83484d92ec..0000000000 --- a/docs/conf/module/phpstan.md +++ /dev/null @@ -1,61 +0,0 @@ -# Configuration for phpstan - -## Supported environments/languages - -* PHP - -## Configuration - -| var | purpose | type | default | -| ------------- |:-------------:| -----:| -----: -| SCA_BLACKLIST_phpstan | Blacklist filter for this tool | space-separated-list | "" -| SCA_PHPSTAN_EXTRA_FATAL | Extra error-IDs leading to build termination when found | space-separated-list | "": -| SCA_PHPSTAN_EXTRA_SUPPRESS | Extra error-IDs to be suppressed | space-separated-list | "" -| SCA_PHPSTAN_FILE_FILTER | File extensions to check | space-separated-list | ".php" - -## Supports - -* [x] suppression of IDs -* [x] terminate build on fatal -* [x] run on recipe -* [ ] run on image -* [ ] run with SCA-layer default settings (see SCA_AVAILABLE_MODULES) - -## Requires - -* [x] requires online access - -## Known error-IDs - -__tbd__ - -## Checking scope - -* [ ] security -* [x] functional defects -* [ ] compliance -* [ ] style issues - -## Statistics - -* ⬛⬛⬛⬛⬜⬜⬜⬜⬜⬜ 04/10 Build Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛ 10/10 Execution Speed -* ⬛⬛⬛⬛⬛⬛⬛⬛⬛⬜ 09/10 Quality - -## Score mapping - -### Error considered as security relevant - -* n.a. - -### Error considered as functional defect - -* phpstan.phpstan.* - -### Error consired as compliance issue - -* n.a. - -### Error considered as style issue - -* n.a. diff --git a/files/module_list.csv b/files/module_list.csv index 963736da46..6966d7a29a 100644 --- a/files/module_list.csv +++ b/files/module_list.csv @@ -39,7 +39,6 @@ nixauditor,Auditing tool for images,https://github.com/XalfiE/Nix-Auditor,,,x,,, oelint,Bitbake recipe linter,https://github.com/priv-kweihmann/oelint-adv,,,x,x,,,,,,,,,,,,,,x,,,x perl,Perl warnings check,,,,,x,,,,,,,,,,,,,,x,,x, perlcritic,Perl linter,https://metacpan.org/pod/perlcritic,,,,x,,,,,,,,,,,,,,x,,x, -phpstan,PHP linter,https://github.com/phpstan/phpstan,"meta-oe, manual enable",x,,x,,,,,,x,,,,,,,,,,,x pkgqaenc,Enhanced package QA,,,,,x,,,,,,,,,,,,,x,,x,, proselint,Spelling and text linter,https://github.com/amperser/proselint/,,,x,x,,,,,,,,,,x,,,,,,,x protolint,Lint protobuf files,https://github.com/yoheimuta/protolint,,,,x,,,,,,,,,,x,,,,x,,,x diff --git a/recipes-sca-rules/sca-recipe-phpstan-rules-native/files/fatal b/recipes-sca-rules/sca-recipe-phpstan-rules-native/files/fatal deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phpstan-rules-native/files/suppress b/recipes-sca-rules/sca-recipe-phpstan-rules-native/files/suppress deleted file mode 100755 index e69de29bb2..0000000000 diff --git a/recipes-sca-rules/sca-recipe-phpstan-rules-native/sca-recipe-phpstan-rules-native_1.0.bb b/recipes-sca-rules/sca-recipe-phpstan-rules-native/sca-recipe-phpstan-rules-native_1.0.bb deleted file mode 100755 index aa68bdc89f..0000000000 --- a/recipes-sca-rules/sca-recipe-phpstan-rules-native/sca-recipe-phpstan-rules-native_1.0.bb +++ /dev/null @@ -1,19 +0,0 @@ -SUMMARY = "SCA ruleset for phpstan at recipes" -DESCRIPTION = "Rules to configure how phpstan 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}/fatal" "${D}${datadir}/phpstan-recipe-fatal" - install "${WORKDIR}/suppress" "${D}${datadir}/phpstan-recipe-suppress" -} - -FILES:${PN} = "${datadir}" diff --git a/recipes-sca/phpstan-native/files/phpstan.sca.description b/recipes-sca/phpstan-native/files/phpstan.sca.description deleted file mode 100644 index 09388dabcc..0000000000 --- a/recipes-sca/phpstan-native/files/phpstan.sca.description +++ /dev/null @@ -1,27 +0,0 @@ -{ - "buildspeed": 4, - "execspeed": 10, - "languages": [ - "php" - ], - "uses": [ - "@php" - ], - "quality": 9, - "scope": [ - "functional" - ], - "score": { - "functional": [ - "phpstan.phpstan..*" - ] - }, - "test": { - "findings": [ - "bad-php" - ], - "no-findings": [ - "busybox" - ] - } -} \ No newline at end of file diff --git a/recipes-sca/phpstan-native/phpstan-native_1.5.7.bb b/recipes-sca/phpstan-native/phpstan-native_1.5.7.bb deleted file mode 100755 index d3b853b458..0000000000 --- a/recipes-sca/phpstan-native/phpstan-native_1.5.7.bb +++ /dev/null @@ -1,24 +0,0 @@ -SUMMARY = "PHP Static Analysis Tool - discover bugs in your code without running it!" -HOMEPAGE = "https://github.com/phpstan/phpstan" - -DEFAULT_PREFERENCE = "${SCA_DEFAULT_PREFERENCE}" -LICENSE = "MIT" -LIC_FILES_CHKSUM = "file://LICENSE;md5=bd7d90c38753ff54df51817ac7d4e5ff" - -SRC_URI = "git://github.com/phpstan/phpstan.git;branch=1.5.x;protocol=https" -SRCREV = "7fb7e2e1e9f3d59a26a413b2d3d5e47f0edb75ac" -PHPCOMPOSER_PKGS_NAME = "phpstan/phpstan:${PV}" - -S = "${WORKDIR}/git" - -inherit phpcomposer -inherit sca-description -inherit native - -SCA_TOOL_DESCRIPTION = "phpstan" - -do_compile:prepend() { - rm -f ${S}/composer.json ${S}/composer.lock -} - -FILES:${PN} = "${bindir}" diff --git a/test/lang_metaoe.txt b/test/lang_metaoe.txt index 34a97739ef..eb7422e7dc 100644 --- a/test/lang_metaoe.txt +++ b/test/lang_metaoe.txt @@ -1,4 +1,3 @@ -phpstan pyright retire secretlint