Skip to content

Commit 43557e6

Browse files
sreichelfballiano
authored andcommitted
Add PHPCodeSniffer to workflow (#2708)
1 parent 5195161 commit 43557e6

File tree

1,987 files changed

+14967
-14608
lines changed

Some content is hidden

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

1,987 files changed

+14967
-14608
lines changed

.github/phpcs-ruleset.xml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0"?>
2+
<ruleset name="OpenMage Standard" namespace="OpenMage\CS\Standard">
3+
<rule ref="PSR2">
4+
<exclude name="Generic.Files.LineLength.TooLong"/>
5+
<exclude name="PSR1.Classes.ClassDeclaration.MissingNamespace"/>
6+
<exclude name="PSR1.Files.SideEffects.FoundWithSymbols"/>
7+
<exclude name="PSR2.Classes.ClassDeclaration.ExtendsLine"/>
8+
<exclude name="PSR2.Classes.PropertyDeclaration.Underscore"/>
9+
<exclude name="PSR2.Methods.FunctionCallSignature.Indent"/>
10+
<exclude name="PSR2.Methods.MethodDeclaration.Underscore"/>
11+
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps"/>
12+
</rule>
13+
<rule ref="PSR12">
14+
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.CloseParenthesisLine"/>
15+
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine"/>
16+
<exclude name="PSR12.ControlStructures.ControlStructureSpacing.LineIndent"/>
17+
<exclude name="PSR12.Files.FileHeader.SpacingAfterBlock"/>
18+
</rule>
19+
<!--
20+
<rule ref="Ecg">
21+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed"/>
22+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed"/>
23+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.Found"/>
24+
<exclude name="Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClass"/>
25+
<exclude name="Generic.Commenting.Todo.TaskFound"/>
26+
<exclude name="Generic.Metrics.CyclomaticComplexity.TooHigh"/>
27+
<exclude name="Ecg.Classes.Mysql4.Found"/>
28+
<exclude name="Ecg.PHP.PrivateClassMember.PrivateClassMemberError"/>
29+
</rule>
30+
-->
31+
</ruleset>

.github/workflows/phpcs.yml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: "PHPCodeSniffer Code Style Analyses"
2+
3+
on:
4+
# Run on all pushes and on all pull requests.
5+
# Prevent the build from running when there are only irrelevant changes.
6+
push:
7+
paths:
8+
- '**.php'
9+
- '.github/phpcs*'
10+
- '.github/workflows/phpcs*'
11+
pull_request:
12+
paths:
13+
- '**.php'
14+
- '.github/phpcs*'
15+
- '.github/workflows/phpcs*'
16+
# Allow manually triggering the workflow.
17+
workflow_dispatch:
18+
19+
jobs:
20+
phpcs:
21+
runs-on: [ubuntu-latest]
22+
23+
strategy:
24+
matrix:
25+
paths: [
26+
'app/code/core/Mage/',
27+
'lib/Mage/',
28+
'lib/Magento/',
29+
'lib/Varien/',
30+
'app/code/community/'
31+
]
32+
33+
name: PHPCodeSniffer ${{ matrix.paths }}
34+
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v3
38+
39+
- name: Validate composer
40+
run: composer validate --strict
41+
42+
- name: Get composer cache directory
43+
id: composer-cache
44+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
45+
46+
- name: Cache dependencies
47+
uses: actions/cache@v2
48+
with:
49+
path: ${{ steps.composer-cache.outputs.dir }}
50+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
51+
restore-keys: ${{ runner.os }}-composer-
52+
53+
- name: Install dependencies
54+
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*
55+
56+
- name: PHPCodeSniffer
57+
run: php vendor/bin/phpcs -s --report=full --standard=.github/phpcs-ruleset.xml ${{ matrix.paths }}
58+
continue-on-error: ${{ matrix.paths == 'app/code/community/' }}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Mage_Admin_Helper_Data extends Mage_Core_Helper_Abstract
3232
/**
3333
* Configuration path to expiration period of reset password link
3434
*/
35-
const XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD
35+
public const XML_PATH_ADMIN_RESET_PASSWORD_LINK_EXPIRATION_PERIOD
3636
= 'default/admin/emails/password_reset_link_expiration_period';
3737

3838
/**

app/code/core/Mage/Admin/Model/Acl.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,31 @@ class Mage_Admin_Model_Acl extends Zend_Acl
3737
* All the group roles are prepended by G
3838
*
3939
*/
40-
const ROLE_TYPE_GROUP = 'G';
40+
public const ROLE_TYPE_GROUP = 'G';
4141

4242
/**
4343
* All the user roles are prepended by U
4444
*
4545
*/
46-
const ROLE_TYPE_USER = 'U';
46+
public const ROLE_TYPE_USER = 'U';
4747

4848
/**
4949
* Permission level to deny access
5050
*
5151
*/
52-
const RULE_PERM_DENY = 0;
52+
public const RULE_PERM_DENY = 0;
5353

5454
/**
5555
* Permission level to inheric access from parent role
5656
*
5757
*/
58-
const RULE_PERM_INHERIT = 1;
58+
public const RULE_PERM_INHERIT = 1;
5959

6060
/**
6161
* Permission level to allow access
6262
*
6363
*/
64-
const RULE_PERM_ALLOW = 2;
64+
public const RULE_PERM_ALLOW = 2;
6565

6666
/**
6767
* Get role registry object or create one

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function __construct()
4848
if ($adminhtmlConfig) {
4949
$this->_adminhtmlConfig = new Varien_Simplexml_Config($adminhtmlConfig);
5050
} else {
51-
$adminhtmlConfig = new Varien_Simplexml_Config;
51+
$adminhtmlConfig = new Varien_Simplexml_Config();
5252
$adminhtmlConfig->loadString('<?xml version="1.0"?><config></config>');
5353
Mage::getConfig()->loadModulesConfiguration('adminhtml.xml', $adminhtmlConfig);
5454
$this->_adminhtmlConfig = $adminhtmlConfig;

app/code/core/Mage/Admin/Model/Observer.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
class Mage_Admin_Model_Observer
3030
{
31-
const FLAG_NO_LOGIN = 'no-login';
31+
public const FLAG_NO_LOGIN = 'no-login';
3232

3333
/**
3434
* Handler for controller_action_predispatch event
@@ -132,8 +132,7 @@ public function actionAdminAuthenticate($observer)
132132
return;
133133
}
134134

135-
if (
136-
!(bool) $user->getPasswordUpgraded()
135+
if (!(bool) $user->getPasswordUpgraded()
137136
&& !Mage::helper('core')->getEncryptor()->validateHashByVersion(
138137
$password,
139138
$user->getPassword(),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
class Mage_Admin_Model_Resource_Acl extends Mage_Core_Model_Resource_Db_Abstract
3030
{
31-
const ACL_ALL_RULES = 'all';
31+
public const ACL_ALL_RULES = 'all';
3232

3333
/**
3434
* Initialize resource

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class Mage_Admin_Model_Resource_Block extends Mage_Core_Model_Resource_Db_Abstra
3131
/**
3232
* Cache id
3333
*/
34-
const CACHE_ID = 'permission_block';
34+
public const CACHE_ID = 'permission_block';
3535

3636
/**
3737
* Disallowed names for block

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
class Mage_Admin_Model_Resource_Variable extends Mage_Core_Model_Resource_Db_Abstract
3030
{
31-
const CACHE_ID = 'permission_variable';
31+
public const CACHE_ID = 'permission_variable';
3232

3333
protected function _construct()
3434
{

app/code/core/Mage/Admin/Model/Rules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,12 @@ class Mage_Admin_Model_Rules extends Mage_Core_Model_Abstract
5050
/**
5151
* Allowed permission code
5252
*/
53-
const RULE_PERMISSION_ALLOWED = 'allow';
53+
public const RULE_PERMISSION_ALLOWED = 'allow';
5454

5555
/**
5656
* Denied permission code
5757
*/
58-
const RULE_PERMISSION_DENIED = 'deny';
58+
public const RULE_PERMISSION_DENIED = 'deny';
5959

6060
protected function _construct()
6161
{

0 commit comments

Comments
 (0)