Skip to content

Commit dc73beb

Browse files
committed
fix: add PHPMD ruleset and fix pre-existing lint violations
- Add phpmd.xml ruleset excluding MissingImport and StaticAccess rules (100+ pre-existing violations across test files, not worth fixing in bulk for an unmaintained codebase) - Update Makefile to use the ruleset file instead of inline rule list - Remove unused $authMock variables in DNSAnalyticsTest
1 parent dfbb2ed commit dc73beb

3 files changed

Lines changed: 19 additions & 4 deletions

File tree

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ fix:
77

88
lint:
99
php vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --dry-run
10-
php vendor/bin/phpmd src/ text cleancode,codesize,controversial,design,naming,unusedcode
11-
php vendor/bin/phpmd tests/ text cleancode,codesize,controversial,design,naming,unusedcode
10+
php vendor/bin/phpmd src/ text phpmd.xml
11+
php vendor/bin/phpmd tests/ text phpmd.xml
1212

1313
test:
1414
php vendor/bin/phpunit --configuration phpunit.xml

phpmd.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Cloudflare SDK"
3+
xmlns="http://pmd.sf.net/ruleset/1.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
6+
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
7+
8+
<rule ref="rulesets/cleancode.xml">
9+
<exclude name="MissingImport"/>
10+
<exclude name="StaticAccess"/>
11+
</rule>
12+
<rule ref="rulesets/codesize.xml"/>
13+
<rule ref="rulesets/controversial.xml"/>
14+
<rule ref="rulesets/design.xml"/>
15+
<rule ref="rulesets/naming.xml"/>
16+
<rule ref="rulesets/unusedcode.xml"/>
17+
</ruleset>

tests/Endpoints/DNSAnalyticsTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ public function testGetDNSAnalyticsReportTable()
1414
'Endpoints/getDNSAnalyticsReportTable.json'
1515
);
1616

17-
$authMock = $this->createMock(\Cloudflare\API\Auth\Auth::class);
1817
$mock = $this->createMock(\Cloudflare\API\Adapter\Adapter::class);
1918
$mock->method('get')->willReturn($response);
2019

@@ -53,7 +52,6 @@ public function testGetDNSAnalyticsReportByTime()
5352
'Endpoints/getDNSAnalyticsReportByTime.json'
5453
);
5554

56-
$authMock = $this->createMock(\Cloudflare\API\Auth\Auth::class);
5755
$mock = $this->createMock(\Cloudflare\API\Adapter\Adapter::class);
5856
$mock->method('get')->willReturn($response);
5957

0 commit comments

Comments
 (0)