Closed MikeiLL closed 4 years ago
Some of these errors is on you to ignore it or fix it. I use this https://github.com/CodeAtCode/CodeatCS/blob/master/codeat-phpmd.xml config file for phpmd. About the blacklisted words again it is on you if follow them or not.
To suppress warnings: https://phpmd.org/documentation/suppress-warnings.html
Some of these errors is on you to ignore it or fix it. I use this https://github.com/CodeAtCode/CodeatCS/blob/master/codeat-phpmd.xml config file for phpmd. About the blacklisted words again it is on you if follow them or not.
Where does that file go? I have tried in the main plugin directory under the names phpmd.xml
, codeat-phpmd.xml
and ruleset.xml
. Also tried phpmd.xml
in my home directory, where composer is configured.
You need to pass to phpmd as written at https://phpmd.org/documentation/index.html
You need to pass to phpmd as written at https://phpmd.org/documentation/index.html
It's being triggered by git commit
.
So you need to configure grumphp.yml
and check grumphp settings.
Got the blacklist error to go away.
But the ruleset from your link isn't making the list of warnings go away.
#grumphp.yml
---
parameters:
git_dir: .
bin_dir: composer/bin
ignore_unstaged_changes: false
tasks:
composer:
with_dependencies: false
strict: false
phpmd:
ruleset: ['phpmd.xml']
triggered_by:
- php
git_blacklist:
keywords:
- print_r(
- var_dump(
triggered_by:
- php
And in same directory:
#phpmd.xml
<?xml version="1.0"?>
<ruleset name="Standard PHPMD"
xmlns="http://pmd.sf.net/ruleset/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0
http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="
http://pmd.sf.net/ruleset_xml_schema.xsd">
<description>
Standard PHPMD
</description>
<rule ref="rulesets/cleancode.xml" >
<exclude name="MissingImport"/>
</rule>
<rule ref="rulesets/codesize.xml" />
<rule ref="rulesets/design.xml" />
<rule ref="rulesets/naming.xml" />
<rule ref="rulesets/unusedcode.xml" >
<exclude name="UnusedLocalVariable"/>
<exclude name="UnusedFormalParameter"/>
</rule>
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable">
<priority>1</priority>
<properties>
<property name="allow-unused-foreach-variables" value="true" />
</properties>
</rule>
<!-- @see https://github.com/phpmd/phpmd/issues/279 -->
<exclude-pattern>index.php</exclude-pattern>
</ruleset>
Do I need to make copies of the ruleset
s from vendor/phpmd
?
Not sure if this is the expected fix, but I copied the resources/ruleset
s from vendor/phpmd
and made modifications so that the errors went away.
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▄▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▄▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▐█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀█▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▌
▀▀▓▓▓▓▓▓▓▓▓▓▓▓█▀▀▀▀▀▀▀▀▀▀▀▀▀▀████████████▄
▄████████▀▀▀▀▀ ██████████
███████▀ ██████▀
▐████ ██▌ ██ ████▌
▐█▌ ███
█▌ ▄▄ ▄▄ ▐███
███ ▄▄▄▄▄▄▄▄▄▄▄▄ ▐███
██▄ ▐███████████████████████████
█▀█████████▌▀▀▀▀▀▀▀▀▀██████████▌▐
███████████▄▄▄▄▄▄▄███████████▌
▐█████████████████████████████
█████████████████████████████
██ █████████████████████▐██▀
▀ ▐███████████████████▌ ▐▀
████▀████████▀▐███
▀█▌ ▐█████ ▐█▌
██▀ ▐▀
_ _ _ _ _
/ \ | | | __ _ ___ ___ __| | |
/ _ \ | | | / _` |/ _ \ / _ \ / _` | |
/ ___ \| | | | (_| | (_) | (_) | (_| |_|
/_/ \_\_|_| \__, |\___/ \___/ \__,_(_)
|___/
[master 33afd7a] Barebones phpmd configs to make warnings go away.
7 files changed, 1574 insertions(+)
create mode 100644 phpmd.xml
create mode 100644 rulesets/cleancode.xml
create mode 100644 rulesets/codesize.xml
create mode 100644 rulesets/controversial.xml
create mode 100644 rulesets/design.xml
create mode 100644 rulesets/naming.xml
create mode 100644 rulesets/unusedcode.xml
I would think that the generated (or cloned) boilerplate files should also contain phpmd.xml
and ruleset
s by which the codebase will be passing. Maybe this learning curve is part of what you are going for.
I'm not sure if this current project is going to warrant testing, but I'm excited to get into Codeception.
Copy the ruleset isn't a good practice because they can change etc, the best way instead is to disable the one that you down want. Usually for phpmd the ruleset aren't project based like phpcs more global so don't define them in the boilerplate is a way to let people customize by their needs. Anyway I think that I can do some changes for that.
Usually for phpmd the ruleset aren't project based like phpcs more global so don't define them in the boilerplate is a way to let people customize by their needs.
If they are global, do the configuration files go in your home directory, as opposed to the plugin directory?
This is on you, I suggest to you to check the phpmd documentation and set as you prefer
I'm new to PHPMD. Love it.
Getting the following (cool picture and) errors:
Do you recommend I ignore some of that in a config file, fix them? Thanks.