Skip to content

Commit e47aa19

Browse files
authored
PHPMD: remove unused private methods/fields (#4397)
* remove unused private methods/fields * fixes - but one * baseline - see phpmd/phpmd#1218
1 parent bcf0e84 commit e47aa19

File tree

9 files changed

+11
-142
lines changed

9 files changed

+11
-142
lines changed

.phpmd.dist.baseline.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
<?xml version="1.0"?>
22
<phpmd-baseline>
3-
<violation rule="PHPMD\Rule\UnusedPrivateMethod" file="app/code/core/Mage/Admin/Model/Resource/User.php" method="_encryptPassword"/>
43
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/Admin/Model/Session.php"/>
54
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/Adminhtml/Block/Report/Sales/Grid/Column/Renderer/Date.php"/>
65
<violation rule="PHPMD\Rule\UnusedPrivateMethod" file="app/code/core/Mage/Adminhtml/Block/Sales/Order/View/Tab/History.php" method="_sortHistoryByTimestamp"/>
@@ -9,16 +8,11 @@
98
<violation rule="PHPMD\Rule\Design\CountInLoopExpression" file="app/code/core/Mage/Catalog/Model/Layer/Filter/Price.php"/>
109
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/Catalog/Model/Product/Api.php"/>
1110
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/Catalog/Model/Product/Api/V2.php"/>
12-
<violation rule="PHPMD\Rule\UnusedPrivateMethod" file="app/code/core/Mage/Checkout/Block/Cart/Sidebar.php" method="_addTax"/>
13-
<violation rule="PHPMD\Rule\UnusedPrivateField" file="app/code/core/Mage/Checkout/Block/Onepage/Success.php"/>
1411
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/Core/Model/Cache.php"/>
1512
<violation rule="PHPMD\Rule\Design\CountInLoopExpression" file="app/code/core/Mage/Core/Model/Layout.php"/>
1613
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/GiftMessage/Model/Observer.php"/>
1714
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/GiftMessage/controllers/IndexController.php"/>
1815
<violation rule="PHPMD\Rule\Design\EmptyCatchBlock" file="app/code/core/Mage/ImportExport/Model/Resource/Helper/Mysql4.php"/>
19-
<violation rule="PHPMD\Rule\UnusedPrivateMethod" file="app/code/core/Mage/Log/Model/Aggregation.php" method="_removeEmpty"/>
20-
<violation rule="PHPMD\Rule\UnusedPrivateMethod" file="app/code/core/Mage/Paypal/Model/Config.php" method="_matchBnCountryCode"/>
2116
<violation rule="PHPMD\Rule\Design\CountInLoopExpression" file="app/code/core/Mage/Paypal/Model/Report/Settlement.php"/>
22-
<violation rule="PHPMD\Rule\UnusedPrivateField" file="app/code/core/Mage/Sales/Model/Order/Status/History.php"/>
2317
<violation rule="PHPMD\Rule\Design\CountInLoopExpression" file="app/code/core/Mage/Usa/Model/Shipping/Carrier/Usps.php"/>
2418
</phpmd-baseline>

.phpmd.dist.xml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,25 @@
7171

7272
<!-- NAMING
7373
[-] BooleanGetMethodName
74-
[ ] ConstantNamingConventions
75-
[ ] ConstructorWithNameAsEnclosingClass
74+
[x] ConstantNamingConventions
75+
[x] ConstructorWithNameAsEnclosingClass
7676
[-] LongClassName
77-
[ ] ShortClassName
77+
[x] ShortClassName
7878
[-] LongVariable
79-
[?] ShortVariable - TMP disabled
80-
[ ] ShortMethodName
79+
[x] ShortVariable
80+
[x] ShortMethodName - TMP disabled
8181
-->
82-
<!-- <rule ref="rulesets/naming.xml/ShortVariable">-->
83-
<!-- <properties>-->
84-
<!-- <property name="exceptions" value="a,b,e,id,idx,io,ip,to,x,y,x1,x2,y1,y2" />-->
85-
<!-- </properties>-->
86-
<!-- </rule>-->
8782
<rule ref="rulesets/naming.xml">
8883
<exclude name="BooleanGetMethodName" />
8984
<exclude name="LongClassName" />
9085
<exclude name="LongVariable" />
9186
<exclude name="ShortVariable" />
9287
</rule>
88+
<!-- <rule ref="rulesets/naming.xml/ShortVariable">-->
89+
<!-- <properties>-->
90+
<!-- <property name="exceptions" value="a,b,x,y,x1,x2,y1,y2" />-->
91+
<!-- </properties>-->
92+
<!-- </rule>-->
9393
<rule ref="rulesets/naming.xml/ShortMethodName" />
9494

9595
<!-- DESIGN

.phpstan.dist.baseline.neon

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ parameters:
2525
count: 1
2626
path: app/code/core/Mage/Admin/Model/Resource/Roles.php
2727

28-
-
29-
message: "#^Method Mage_Admin_Model_Resource_User\\:\\:_encryptPassword\\(\\) is unused\\.$#"
30-
count: 1
31-
path: app/code/core/Mage/Admin/Model/Resource/User.php
32-
3328
-
3429
message: "#^Call to an undefined method Mage_Admin_Model_Resource_Roles\\:\\:update\\(\\)\\.$#"
3530
count: 1
@@ -2385,11 +2380,6 @@ parameters:
23852380
count: 1
23862381
path: app/code/core/Mage/Checkout/Block/Cart/Shipping.php
23872382

2388-
-
2389-
message: "#^Method Mage_Checkout_Block_Cart_Sidebar\\:\\:_addTax\\(\\) is unused\\.$#"
2390-
count: 1
2391-
path: app/code/core/Mage/Checkout/Block/Cart/Sidebar.php
2392-
23932383
-
23942384
message: "#^Method Mage_Checkout_Block_Onepage_Billing\\:\\:_getTaxvat\\(\\) should return Mage_Customer_Block_Widget_Taxvat but returns Mage_Core_Block_Abstract\\|false\\.$#"
23952385
count: 1
@@ -2405,11 +2395,6 @@ parameters:
24052395
count: 1
24062396
path: app/code/core/Mage/Checkout/Block/Onepage/Progress.php
24072397

2408-
-
2409-
message: "#^Property Mage_Checkout_Block_Onepage_Success\\:\\:\\$_order is unused\\.$#"
2410-
count: 1
2411-
path: app/code/core/Mage/Checkout/Block/Onepage/Success.php
2412-
24132398
-
24142399
message: "#^PHPDoc tag @var with type Mage_Sales_Model_Quote_Item is not subtype of native type null\\.$#"
24152400
count: 1
@@ -4070,11 +4055,6 @@ parameters:
40704055
count: 1
40714056
path: app/code/core/Mage/Log/Model/Aggregation.php
40724057

4073-
-
4074-
message: "#^Method Mage_Log_Model_Aggregation\\:\\:_removeEmpty\\(\\) is unused\\.$#"
4075-
count: 1
4076-
path: app/code/core/Mage/Log/Model/Aggregation.php
4077-
40784058
-
40794059
message: "#^Parameter \\#1 \\$id of method Mage_Log_Model_Aggregation\\:\\:_update\\(\\) expects int, string given\\.$#"
40804060
count: 1
@@ -4225,11 +4205,6 @@ parameters:
42254205
count: 1
42264206
path: app/code/core/Mage/Paypal/Model/Cart.php
42274207

4228-
-
4229-
message: "#^Method Mage_Paypal_Model_Config\\:\\:_matchBnCountryCode\\(\\) is unused\\.$#"
4230-
count: 1
4231-
path: app/code/core/Mage/Paypal/Model/Config.php
4232-
42334208
-
42344209
message: "#^Negated boolean expression is always true\\.$#"
42354210
count: 1
@@ -4955,16 +4930,6 @@ parameters:
49554930
count: 1
49564931
path: app/code/core/Mage/Sales/Model/Order/Shipment/Api/V2.php
49574932

4958-
-
4959-
message: "#^Method Mage_Sales_Model_Order_Status_History\\:\\:getStatusLabel\\(\\) should return string but return statement is missing\\.$#"
4960-
count: 1
4961-
path: app/code/core/Mage/Sales/Model/Order/Status/History.php
4962-
4963-
-
4964-
message: "#^Property Mage_Sales_Model_Order_Status_History\\:\\:\\$_shouldSetOrderBeforeSave is never read, only written\\.$#"
4965-
count: 1
4966-
path: app/code/core/Mage/Sales/Model/Order/Status/History.php
4967-
49684933
-
49694934
message: "#^Parameter \\#2 \\$totalConfig of method Mage_Sales_Model_Config_Ordered\\:\\:_prepareConfigArray\\(\\) expects Mage_Core_Model_Config_Element, array given\\.$#"
49704935
count: 1

app/code/core/Mage/Admin/Model/Resource/User.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,6 @@ public function hasAssigned2Role($user)
124124
}
125125
}
126126

127-
/**
128-
* Encrypt password
129-
*
130-
* @param string $pwStr
131-
* @return string
132-
*/
133-
private function _encryptPassword($pwStr)
134-
{
135-
return Mage::helper('core')->getHash($pwStr, Mage_Admin_Model_User::HASH_SALT_LENGTH);
136-
}
137-
138127
/**
139128
* Set created/modified values before user save
140129
*

app/code/core/Mage/Checkout/Block/Cart/Sidebar.php

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -112,26 +112,6 @@ public function getSubtotalInclTax()
112112
return $this->getSubtotal(false);
113113
}
114114

115-
/**
116-
* Add tax to amount
117-
*
118-
* @param float $price
119-
* @param bool $exclShippingTax
120-
* @return float
121-
*/
122-
private function _addTax($price, $exclShippingTax = true)
123-
{
124-
$totals = $this->getTotals();
125-
if (isset($totals['tax'])) {
126-
if ($exclShippingTax) {
127-
$price += $totals['tax']->getValue() - $this->_getShippingTaxAmount();
128-
} else {
129-
$price += $totals['tax']->getValue();
130-
}
131-
}
132-
return $price;
133-
}
134-
135115
/**
136116
* Get shipping tax amount
137117
*

app/code/core/Mage/Checkout/Block/Onepage/Success.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@
3030
*/
3131
class Mage_Checkout_Block_Onepage_Success extends Mage_Core_Block_Template
3232
{
33-
/**
34-
* @deprecated after 1.4.0.1
35-
*/
36-
private $_order;
37-
3833
/**
3934
* Check order print availability
4035
*

app/code/core/Mage/Log/Model/Aggregation.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,6 @@ public function run()
5151
}
5252
}
5353

54-
/**
55-
* Remove empty records before $lastDate
56-
*
57-
* @param string $lastDate
58-
* @return Mage_Log_Model_Resource_Aggregation
59-
*/
60-
private function _removeEmpty($lastDate)
61-
{
62-
return $this->_getResource()->removeEmpty($lastDate);
63-
}
64-
6554
/**
6655
* Process
6756
*

app/code/core/Mage/Paypal/Model/Config.php

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,43 +1654,6 @@ protected function _getSpecificConfigPath($fieldName)
16541654
return $path;
16551655
}
16561656

1657-
/**
1658-
* Check whether specified country code is supported by build notation codes for specific countries
1659-
*
1660-
* @param string $code
1661-
* @return string|null
1662-
*/
1663-
private function _matchBnCountryCode($code)
1664-
{
1665-
switch ($code) {
1666-
// GB == UK
1667-
case 'GB':
1668-
return 'UK';
1669-
// Australia, Austria, Belgium, Canada, China, France, Germany, Hong Kong, Italy
1670-
case 'AU':
1671-
case 'AT':
1672-
case 'BE':
1673-
case 'CA':
1674-
case 'CN':
1675-
case 'FR':
1676-
case 'DE':
1677-
case 'HK':
1678-
case 'IT':
1679-
// Japan, Mexico, Netherlands, Poland, Singapore, Spain, Switzerland, United Kingdom, United States
1680-
case 'JP':
1681-
case 'MX':
1682-
case 'NL':
1683-
case 'PL':
1684-
case 'SG':
1685-
case 'ES':
1686-
case 'CH':
1687-
case 'UK':
1688-
case 'US':
1689-
return $code;
1690-
}
1691-
return null;
1692-
}
1693-
16941657
/**
16951658
* Map PayPal Standard config fields
16961659
*

app/code/core/Mage/Sales/Model/Order/Status/History.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ class Mage_Sales_Model_Order_Status_History extends Mage_Sales_Model_Abstract
4646
*/
4747
protected $_order;
4848

49-
/**
50-
* Whether setting order again is required (for example when setting non-saved yet order)
51-
* @deprecated after 1.4, wrong logic of setting order id
52-
* @var bool
53-
*/
54-
private $_shouldSetOrderBeforeSave = false;
55-
5649
protected $_eventPrefix = 'sales_order_status_history';
5750
protected $_eventObject = 'status_history';
5851

@@ -127,6 +120,7 @@ public function getStatusLabel()
127120
if ($this->getOrder()) {
128121
return $this->getOrder()->getConfig()->getStatusLabel($this->getStatus());
129122
}
123+
return '';
130124
}
131125

132126
/**

0 commit comments

Comments
 (0)