Skip to content

Commit

Permalink
Merge pull request 'feature: integrated phpmd and baseline' (#4) from…
Browse files Browse the repository at this point in the history
… introduce_phpmd into develop

Reviewed-on: https://lab.sdo.sh/SDO/Seafile-PHP-SDK/pulls/4
  • Loading branch information
Rene Schmidt committed Dec 23, 2024
2 parents d6ee026 + c680273 commit d33a3cf
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .forgejo/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Prepare tests
run: composer run-script tests_prepare

- name: Run PHPMD
run: composer run phpmd

- name: Run Rector
run: composer run rector

Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ jobs:
- name: Run Rector
run: composer run rector

- name: Run PHPMD
run: composer run phpmd

- name: Run PHPStan
run: composer run phpstan

Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ vendor/
.env
bin/run_tests_*.sh
internal_requests/
.phpunit.result.cache
.phpunit.result.cache
.phpmd.result-cache.php
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
"phpunit/php-timer": "~5.0",
"fzaninotto/faker": "~1.5",
"phpstan/phpstan": "^1.11",
"rector/rector": "^1.2"
"rector/rector": "^1.2",
"phpmd/phpmd": "^2.15.0"
},
"type": "library",
"autoload": {
Expand All @@ -49,6 +50,8 @@
}
},
"scripts": {
"create-phpmd-baseline": "./vendor/bin/phpmd -v --cache . text phpmd.xml --generate-baseline",
"phpmd": "./vendor/bin/phpmd -v --cache . text phpmd.xml",
"phpstan": "./vendor/bin/phpstan analyse --memory-limit 2G --configuration phpstan.neon src test",
"phpunit": "./vendor/bin/phpunit --log-junit ./build/logs/junit.xml test",
"rector": "./vendor/bin/rector --dry-run --no-ansi --no-progress-bar",
Expand Down
46 changes: 46 additions & 0 deletions phpmd.baseline.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?xml version="1.0"?>
<phpmd-baseline>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Resource/Avatar.php"/>
<violation rule="PHPMD\Rule\CleanCode\BooleanArgumentFlag" file="src/Resource/Directory.php"/>
<violation rule="PHPMD\Rule\CleanCode\BooleanArgumentFlag" file="src/Resource/File.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="src/Resource/File.php"/>
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/Resource/File.php"/>
<violation rule="PHPMD\Rule\Naming\LongVariable" file="src/Resource/ShareLinks.php"/>
<violation rule="PHPMD\Rule\Design\TooManyFields" file="src/Type/Account.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Type/Account.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Type/DirectoryItem.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Type/FileHistoryItem.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Type/Group.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="src/Type/Library.php"/>
<violation rule="PHPMD\Rule\CleanCode\StaticAccess" file="src/Type/Type.php"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/functional/FunctionalTestCase.php" method="checkFunctionalTestsSetUpCorrectly"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/functional/FunctionalTestCase.php" method="getClient"/>
<violation rule="PHPMD\Rule\CleanCode\StaticAccess" file="test/functional/FunctionalTestCase.php"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/functional/FunctionalTestCase.php" method="getFaker"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/functional/FunctionalTestCase.php" method="getTestLibraryType"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="test/functional/Resource/AccountTest.php"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/functional/Resource/FileTest.php" method="testHistory"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/functional/Resource/FileTest.php" method="testRename"/>
<violation rule="PHPMD\Rule\UnusedLocalVariable" file="test/functional/Resource/FileTest.php"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/functional/Resource/ShareLinksTest.php" method="testShareLinks"/>
<violation rule="PHPMD\Rule\Naming\LongVariable" file="test/functional/Resource/ShareLinksTest.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="test/functional/Resource/ShareLinksTest.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="test/functional/Resource/ShareLinksTest.php"/>
<violation rule="PHPMD\Rule\Naming\ShortVariable" file="test/unit/Resource/AvatarTest.php"/>
<violation rule="PHPMD\Rule\Design\TooManyPublicMethods" file="test/unit/Resource/DirectoryTest.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="test/unit/Resource/DirectoryTest.php"/>
<violation rule="PHPMD\Rule\Design\TooManyMethods" file="test/unit/Resource/FileTest.php"/>
<violation rule="PHPMD\Rule\Design\TooManyPublicMethods" file="test/unit/Resource/FileTest.php"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/unit/Resource/FileTest.php" method="testDownloadFromDirFileExists"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/unit/Resource/FileTest.php" method="testUpload"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/unit/Resource/FileTest.php" method="testUpdate"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/unit/Resource/FileTest.php" method="testUpdateMultiPartParams"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/unit/Resource/FileTest.php" method="testUpdateMultiPartParamsNewFilename"/>
<violation rule="PHPMD\Rule\Controversial\Superglobals" file="test/unit/Resource/FileTest.php" method="testUploadMultiPartParams"/>
<violation rule="PHPMD\Rule\Design\TooManyPublicMethods" file="test/unit/Resource/LibraryTest.php"/>
<violation rule="PHPMD\Rule\Naming\LongVariable" file="test/unit/Resource/ShareLinksTest.php"/>
<violation rule="PHPMD\Rule\CleanCode\ElseExpression" file="test/unit/Resource/ShareLinksTest.php"/>
<violation rule="PHPMD\Rule\CyclomaticComplexity" file="test/unit/Resource/StarredFileTest.php" method="testStar"/>
<violation rule="PHPMD\Rule\CleanCode\BooleanArgumentFlag" file="test/unit/Stubs/FileResourceStub.php"/>
<violation rule="PHPMD\Rule\CleanCode\StaticAccess" file="test/unit/Type/TypeUnitTest.php"/>
</phpmd-baseline>
50 changes: 50 additions & 0 deletions phpmd.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<ruleset name="PHPMD ruleset"
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 https://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:noNamespaceSchemaLocation="https://pmd.sf.net/ruleset_xml_schema.xsd">
<description>My PHPMD ruleset</description>

<exclude-pattern>*/vendor/</exclude-pattern>

<include-pattern>*/src/</include-pattern>
<include-pattern>*/test/</include-pattern>

<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
<rule ref="rulesets/cleancode.xml/ElseExpression" />
<rule ref="rulesets/cleancode.xml/StaticAccess" />
<rule ref="rulesets/codesize.xml/CyclomaticComplexity" />
<rule ref="rulesets/codesize.xml/NPathComplexity" />
<rule ref="rulesets/codesize.xml/ExcessiveMethodLength" />
<rule ref="rulesets/codesize.xml/ExcessiveClassLength" />
<rule ref="rulesets/codesize.xml/ExcessiveParameterList" />
<rule ref="rulesets/codesize.xml/ExcessivePublicCount" />
<rule ref="rulesets/codesize.xml/TooManyFields" />
<rule ref="rulesets/codesize.xml/TooManyMethods" />
<rule ref="rulesets/codesize.xml/TooManyPublicMethods" />
<rule ref="rulesets/codesize.xml/ExcessiveClassComplexity" />
<rule ref="rulesets/controversial.xml/Superglobals" />
<rule ref="rulesets/controversial.xml/CamelCaseClassName" />
<rule ref="rulesets/controversial.xml/CamelCasePropertyName" />
<rule ref="rulesets/controversial.xml/CamelCaseMethodName" />
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
<rule ref="rulesets/controversial.xml/CamelCaseVariableName" />
<rule ref="rulesets/design.xml/ExitExpression" />
<rule ref="rulesets/design.xml/EvalExpression" />
<rule ref="rulesets/design.xml/GotoStatement" />
<rule ref="rulesets/design.xml/NumberOfChildren" />
<rule ref="rulesets/design.xml/DepthOfInheritance" />
<rule ref="rulesets/design.xml/CouplingBetweenObjects" />
<rule ref="rulesets/design.xml/DevelopmentCodeFragment" />
<rule ref="rulesets/naming.xml/ShortVariable" />
<rule ref="rulesets/naming.xml/LongVariable" />
<rule ref="rulesets/naming.xml/ShortMethodName" />
<rule ref="rulesets/naming.xml/ConstructorWithNameAsEnclosingClass" />
<rule ref="rulesets/naming.xml/ConstantNamingConventions" />
<rule ref="rulesets/naming.xml/BooleanGetMethodName" />
<rule ref="rulesets/unusedcode.xml/UnusedPrivateField" />
<rule ref="rulesets/unusedcode.xml/UnusedLocalVariable" />
<rule ref="rulesets/unusedcode.xml/UnusedPrivateMethod" />
<rule ref="rulesets/unusedcode.xml/UnusedFormalParameter" />
</ruleset>

0 comments on commit d33a3cf

Please sign in to comment.