Skip to content

Commit 19e34ed

Browse files
authored
PHPMD: added basic config (#2771)
1 parent 514bb49 commit 19e34ed

File tree

50 files changed

+375
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+375
-1
lines changed

.phpmd.dist.xml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="Custom ruleset"
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+
<description>
8+
OpenMage ruleset
9+
</description>
10+
11+
<!-- UNUSEDCODE
12+
UnusedFormalParameter [fixed]
13+
UnusedLocalVariable
14+
UnusedPrivateField
15+
UnusedPrivateMethod
16+
-->
17+
<rule ref="rulesets/unusedcode.xml" />
18+
19+
<!-- CLEANCODE
20+
BooleanArgumentFlag
21+
ElseExpression
22+
ErrorControlOperator
23+
DuplicatedArrayKey
24+
IfStatementAssignment
25+
MissingImport
26+
StaticAccess
27+
UndefinedVariable
28+
-->
29+
<rule ref="rulesets/cleancode.xml">
30+
<exclude name="BooleanArgumentFlag" />
31+
<exclude name="ElseExpression" /> <!-- can be fixed in some cases -->
32+
<exclude name="IfStatementAssignment" /> <!-- can be fixed -->
33+
<exclude name="MissingImport" /> <!-- can be fixed -->
34+
<exclude name="StaticAccess" />
35+
<exclude name="UndefinedVariable" /> <!-- can be fixed -->
36+
</rule>
37+
<rule ref="rulesets/cleancode.xml/MissingImport">
38+
<properties>
39+
<property name="ignore-global" value="true" />
40+
</properties>
41+
</rule>
42+
43+
<!-- CONTROVERSIAL
44+
CamelCaseClassName
45+
CamelCaseMethodName
46+
CamelCaseParameterName
47+
CamelCasePropertyName
48+
CamelCaseVariableName
49+
Superglobals
50+
-->
51+
<rule ref="rulesets/controversial.xml/CamelCaseMethodName">
52+
<properties>
53+
<property name="allow-underscore" value="true" />
54+
</properties>
55+
</rule>
56+
<rule ref="rulesets/controversial.xml/CamelCaseParameterName" />
57+
<rule ref="rulesets/controversial.xml/CamelCasePropertyName">
58+
<properties>
59+
<property name="allow-underscore" value="true" />
60+
</properties>
61+
</rule>
62+
<rule ref="rulesets/controversial.xml/CamelCaseVariableName">
63+
<properties>
64+
<property name="allow-underscore" value="true" />
65+
</properties>
66+
</rule>
67+
<rule ref="rulesets/controversial.xml/Superglobals" />
68+
69+
<!-- NAMEING
70+
BooleanGetMethodName
71+
ConstantNamingConventions
72+
ConstructorWithNameAsEnclosingClass
73+
LongClassName
74+
ShortClassName
75+
LongVariable
76+
ShortVariable
77+
ShortMethodName
78+
-->
79+
<rule ref="rulesets/naming.xml/ShortVariable">
80+
<properties>
81+
<property name="exceptions" value="a,b,e,id,idx,io,ip,to,x,y,x1,x2,y1,y2" />
82+
</properties>
83+
</rule>
84+
85+
<!-- DESIGN
86+
CountInLoopExpression
87+
CouplingBetweenObjects
88+
DepthOfInheritance
89+
DevelopmentCodeFragment
90+
EmptyCatchBlock
91+
EvalExpression
92+
ExitExpression
93+
GotoStatement
94+
NumberOfChildren
95+
-->
96+
<rule ref="rulesets/design.xml">
97+
<exclude name="CouplingBetweenObjects" />
98+
<exclude name="DepthOfInheritance" />
99+
<exclude name="NumberOfChildren" />
100+
</rule>
101+
102+
<!-- CODESIZE
103+
ExcessiveClassComplexity
104+
ExcessiveClassLength
105+
ExcessiveMethodLength
106+
ExcessiveParameterList
107+
ExcessivePublicCount
108+
CyclomaticComplexity
109+
NPathComplexity
110+
TooManyFields
111+
TooManyMethods
112+
TooManyPublicMethods
113+
-->
114+
<rule ref="rulesets/codesize.xml">
115+
<exclude name="CyclomaticComplexity" />
116+
<exclude name="ExcessiveClassComplexity" />
117+
<exclude name="ExcessiveClassLength" />
118+
<exclude name="ExcessiveMethodLength" />
119+
<exclude name="ExcessivePublicCount" />
120+
<exclude name="NPathComplexity" />
121+
<exclude name="TooManyFields" />
122+
<exclude name="TooManyMethods" />
123+
<exclude name="TooManyPublicMethods" />
124+
</rule>
125+
</ruleset>

app/code/core/Mage/Adminhtml/Block/Customer/Online/Grid/Renderer/Ip.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727
*/
2828
class Mage_Adminhtml_Block_Customer_Online_Grid_Renderer_Ip extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
2929
{
30+
/**
31+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
32+
*/
3033
public function render(Varien_Object $row)
3134
{
3235
/**

app/code/core/Mage/Adminhtml/Block/Widget/Grid/Column/Renderer/Ip.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Ip extends Mage_Adminhtml
3232
*
3333
* @param Varien_Object $row
3434
* @return string
35+
*
36+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
3537
*/
3638
public function render(Varien_Object $row)
3739
{

app/code/core/Mage/Backup/Helper/Data.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ public function turnOnMaintenanceMode()
207207

208208
/**
209209
* Turn off store maintenance mode
210+
*
211+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
210212
*/
211213
public function turnOffMaintenanceMode()
212214
{

app/code/core/Mage/Backup/Model/Backup.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ public function setFile(&$content)
168168
* @todo rewrite to Varien_IO, but there no possibility read part of files.
169169
* @return string
170170
* @throws Mage_Backup_Exception
171+
*
172+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
171173
*/
172174
public function &getFile()
173175
{
@@ -227,6 +229,8 @@ public function deleteFile()
227229
*
228230
* @param bool $write
229231
* @return $this
232+
*
233+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
230234
*/
231235
public function open($write = false)
232236
{
@@ -312,6 +316,8 @@ public function write($string)
312316
* Close open backup file
313317
*
314318
* @return $this
319+
*
320+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
315321
*/
316322
public function close()
317323
{

app/code/core/Mage/Catalog/Model/Api2/Product/Image/Rest/Admin/V1.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ class Mage_Catalog_Model_Api2_Product_Image_Rest_Admin_V1 extends Mage_Catalog_M
3434
* @throws Mage_Api2_Exception
3535
* @param array $data
3636
* @return string|void
37+
*
38+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
3739
*/
3840
protected function _create(array $data)
3941
{

app/code/core/Mage/Catalog/Model/Product/Attribute/Media/Api.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ public function info($productId, $file, $store = null, $identifierType = null)
111111
* @param string|null $identifierType
112112
* @return string
113113
* @throws Mage_Api_Exception
114+
*
115+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
114116
*/
115117
public function create($productId, $data, $store = null, $identifierType = null)
116118
{
@@ -202,6 +204,8 @@ public function create($productId, $data, $store = null, $identifierType = null)
202204
* @param string|null $identifierType
203205
* @return bool
204206
* @throws Mage_Api_Exception
207+
*
208+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
205209
*/
206210
public function update($productId, $file, $data, $store = null, $identifierType = null)
207211
{

app/code/core/Mage/Catalog/Model/Product/Option/Type/File.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,8 @@ public function prepareOptionValueForRequest($optionValue)
617617
* Quote item to order item copy process
618618
*
619619
* @return $this
620+
*
621+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
620622
*/
621623
public function copyQuoteToOrder()
622624
{
@@ -798,6 +800,8 @@ protected function _getUploadMaxFilesize()
798800
*
799801
* @param string $ini_key php.ini Var name
800802
* @return int Setting value
803+
*
804+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
801805
*/
802806
protected function _getBytesIniValue($ini_key)
803807
{

app/code/core/Mage/Cms/Model/Wysiwyg/Images/Storage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public function getDirsCollection($path)
100100
* @param string $path Parent directory path
101101
* @param string $type Type of storage, e.g. image, media etc.
102102
* @return Varien_Data_Collection_Filesystem
103+
*
104+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
103105
*/
104106
public function getFilesCollection($path, $type = null)
105107
{

app/code/core/Mage/Core/Controller/Varien/Front.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ protected function _processRewriteUrl($url)
327327
* By default this feature is enabled in configuration.
328328
*
329329
* @param Mage_Core_Controller_Request_Http $request
330+
*
331+
* @SuppressWarnings(PHPMD.ErrorControlOperator)
330332
*/
331333
protected function _checkBaseUrl($request)
332334
{

0 commit comments

Comments
 (0)