From bf2d388baa4262bb979f8bd05529047e4b42a4c2 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sat, 17 Jun 2017 10:34:34 +0200 Subject: [PATCH 1/7] details --- easy-coding-standard.neon | 9 ++++++--- tests/FileFactory.php | 4 ++-- tests/Helper/ClassAnalyzerTest.php | 2 +- tests/Helper/NamingTest.php | 2 +- tests/Helper/Structure/StructureMetricsTest.php | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/easy-coding-standard.neon b/easy-coding-standard.neon index ecc9e1e..b5723a3 100644 --- a/easy-coding-standard.neon +++ b/easy-coding-standard.neon @@ -94,17 +94,20 @@ checkers: PHP_CodeSniffer\Standards\Squiz\Sniffs\WhiteSpace\SuperfluousWhitespaceSniff: ignoreBlankLines: false - # Symplify: Commenting + # Commenting - Symplify\CodingStandard\Sniffs\Commenting\VarPropertyCommentSniff - # Symplify: Debug + # Control Structures + - Symplify\CodingStandard\Sniffs\ControlStructures\NewClassSniff + + # Debug - Symplify\CodingStandard\Sniffs\Debug\DebugFunctionCallSniff # Namespaces - Symplify\CodingStandard\Sniffs\Namespaces\ClassNamesWithoutPreSlashSniff - PhpCsFixer\Fixer\NamespaceNotation\SingleBlankLineBeforeNamespaceFixer - # Symplify: Naming + # Naming - Symplify\CodingStandard\Sniffs\Naming\AbstractClassNameSniff - Symplify\CodingStandard\Sniffs\Naming\InterfaceNameSniff - Symplify\CodingStandard\Sniffs\Naming\TraitNameSniff diff --git a/tests/FileFactory.php b/tests/FileFactory.php index 6d32108..f7f466d 100644 --- a/tests/FileFactory.php +++ b/tests/FileFactory.php @@ -20,7 +20,7 @@ public function __construct() // initialize Token constants if (! defined('T_NONE')) { - new Tokens(); + new Tokens; } } @@ -61,7 +61,7 @@ private function createRulesetWithConfigAndSniffClass(string $sniffClass, Config private function createConfig(): Config { - $config = new Config(); + $config = new Config; // nulling required, because PEAR Standard is on by default // $config->standards = []; diff --git a/tests/Helper/ClassAnalyzerTest.php b/tests/Helper/ClassAnalyzerTest.php index 2afd1cc..01f9da3 100644 --- a/tests/Helper/ClassAnalyzerTest.php +++ b/tests/Helper/ClassAnalyzerTest.php @@ -21,7 +21,7 @@ final class ClassAnalyzerTest extends TestCase protected function setUp(): void { - $fileFactory = new FileFactory(); + $fileFactory = new FileFactory; $this->file = $fileFactory->createFile(__DIR__ . '/ClassAnalyzerSource/SomeFile.php.inc'); } diff --git a/tests/Helper/NamingTest.php b/tests/Helper/NamingTest.php index 9deabae..f1773d9 100644 --- a/tests/Helper/NamingTest.php +++ b/tests/Helper/NamingTest.php @@ -30,7 +30,7 @@ final class NamingTest extends TestCase protected function setUp(): void { - $this->fileFactory = new FileFactory(); + $this->fileFactory = new FileFactory; } public function test(): void diff --git a/tests/Helper/Structure/StructureMetricsTest.php b/tests/Helper/Structure/StructureMetricsTest.php index ce732ca..d5dd5c4 100644 --- a/tests/Helper/Structure/StructureMetricsTest.php +++ b/tests/Helper/Structure/StructureMetricsTest.php @@ -25,7 +25,7 @@ final class StructureMetricsTest extends TestCase protected function setUp(): void { - $this->fileFactory = new FileFactory(); + $this->fileFactory = new FileFactory; } public function test(): void From 27c859c12fef74985250d1081c35a707b6180343 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sat, 17 Jun 2017 10:41:40 +0200 Subject: [PATCH 2/7] use coveralls instead of scrutinizer --- .coveralls.yml | 3 +++ .gitattributes | 3 ++- .scrutinizer.yml | 2 -- .travis.yml | 6 +++--- README.md | 4 +++- 5 files changed, 11 insertions(+), 7 deletions(-) create mode 100644 .coveralls.yml delete mode 100644 .scrutinizer.yml diff --git a/.coveralls.yml b/.coveralls.yml new file mode 100644 index 0000000..d7cffdd --- /dev/null +++ b/.coveralls.yml @@ -0,0 +1,3 @@ +service_name: travis-ci +coverage_clover: coverage.xml # file generated by phpunit +json_path: coverage.json # file generated by php-coveralls diff --git a/.gitattributes b/.gitattributes index 72cfc28..80aff14 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,8 @@ /tests export-ignore +.coveralls.yml export-ignore .gitattributes export-ignore .gitignore export-ignore -.scrutinizer.yml export-ignore .travis.yml export-ignore LICENSE export-ignore +phpstan.neon export-ignore phpunit.xml export-ignore diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index d73cd74..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,2 +0,0 @@ -tools: - external_code_coverage: true diff --git a/.travis.yml b/.travis.yml index 227a5d6..0578ab8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,11 +23,11 @@ script: - vendor/bin/phpcs src tests -sp --standard=src/ObjectCalisthenics/ruleset.xml --extensions=php --colors --ignore="Slevomat,SniffRunner" after_script: - # upload coverage.xml file to Scrutinizer to analyze it + # upload coverage.xml file to Coveralls to analyze it - | if [[ PHPUNIT_FLAGS != "" ]]; then - wget https://scrutinizer-ci.com/ocular.phar - php ocular.phar code-coverage:upload --format=php-clover coverage.xml + wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar + php coveralls.phar --verbose fi # do not send success notifications, they have no value diff --git a/README.md b/README.md index 71a2e44..845c93d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,9 @@ # Object Calisthenics rules for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) [![Build Status](https://img.shields.io/travis/object-calisthenics/phpcs-calisthenics-rules/master.svg?style=flat-square)](https://travis-ci.org/object-calisthenics/phpcs-calisthenics-rules) -[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/object-calisthenics/phpcs-calisthenics-rules.svg?style=flat-square)](https://scrutinizer-ci.com/g/object-calisthenics/phpcs-calisthenics-rules) + +[![Coverage Status](https://img.shields.io/coveralls//object-calisthenics/phpcs-calisthenics-rules/master.svg?style=flat-square)](https://coveralls.io//object-calisthenics/phpcs-calisthenics-rules/Symplify?branch=master) + [![Downloads](https://img.shields.io/packagist/dt/object-calisthenics/phpcs-calisthenics-rules.svg?style=flat-square)](https://packagist.org/packages/object-calisthenics/phpcs-calisthenics-rules) Object Calisthenics are **set of rules in object-oriented code, that focuses of maintainability, readability, testability and comprehensibility**. We're **pragmatic first** - they are easy to use all together or one by one. From a1ec614bf45a37b5214a881086c521b1055680f7 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sat, 17 Jun 2017 10:43:16 +0200 Subject: [PATCH 3/7] travis: cleanup phpcs command --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0578ab8..31098ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: # check with phpstan (defined in composer.json "scripts" section) - if [[ $RUN_PHPSTAN = 1 ]]; then composer phpstan; fi # run PHP_CodeSniffer with ruleset - - vendor/bin/phpcs src tests -sp --standard=src/ObjectCalisthenics/ruleset.xml --extensions=php --colors --ignore="Slevomat,SniffRunner" + - vendor/bin/phpcs src tests -sp --standard=src/ObjectCalisthenics/ruleset.xml --extensions=php after_script: # upload coverage.xml file to Coveralls to analyze it From 596a77b4577cb6707dbf4de46997e667563d5cc9 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sat, 17 Jun 2017 10:45:44 +0200 Subject: [PATCH 4/7] cleanup --- tests/FileFactory.php | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/tests/FileFactory.php b/tests/FileFactory.php index f7f466d..367af86 100644 --- a/tests/FileFactory.php +++ b/tests/FileFactory.php @@ -26,7 +26,7 @@ public function __construct() public function createFile(string $filePath): File { - $config = $this->createConfig(); + $config = new Config; $ruleset = new Ruleset($config); $file = new File($filePath, $ruleset, $config); @@ -38,7 +38,7 @@ public function createFile(string $filePath): File public function createFileWithSniffClass(string $filePath, string $sniffClass): File { - $config = $this->createConfig(); + $config = new Config; $ruleset = $this->createRulesetWithConfigAndSniffClass($sniffClass, $config); $file = new File($filePath, $ruleset, $config); @@ -53,18 +53,6 @@ private function createRulesetWithConfigAndSniffClass(string $sniffClass, Config $config->sniffs = [$sniffClass]; $config->standards = ['ObjectCalisthenics']; - $ruleset = new Ruleset($config); -// $ruleset->populateTokenListeners(); - - return $ruleset; - } - - private function createConfig(): Config - { - $config = new Config; - // nulling required, because PEAR Standard is on by default -// $config->standards = []; - - return $config; + return new Ruleset($config); } } From e62fd316da94fffdaf61e35c5b41b723529296c8 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sat, 17 Jun 2017 10:47:36 +0200 Subject: [PATCH 5/7] fix phpstan --- .../Sniffs/NamingConventions/NoSetterSniff.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/ObjectCalisthenics/Sniffs/NamingConventions/NoSetterSniff.php b/src/ObjectCalisthenics/Sniffs/NamingConventions/NoSetterSniff.php index bb777f0..05cc164 100644 --- a/src/ObjectCalisthenics/Sniffs/NamingConventions/NoSetterSniff.php +++ b/src/ObjectCalisthenics/Sniffs/NamingConventions/NoSetterSniff.php @@ -29,7 +29,12 @@ public function register(): array */ public function process(File $file, $position): void { - if ($this->methodNameStartsWithSet($file->getDeclarationName($position))) { + $declarationName = $file->getDeclarationName($position); + if ($declarationName === null) { + return; + } + + if ($this->methodNameStartsWithSet($declarationName)) { $file->addError(self::ERROR_MESSAGE, $position, self::class); } } From 03d248cfe82007369f880fbb1fdfb0b735c74122 Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sat, 17 Jun 2017 10:47:49 +0200 Subject: [PATCH 6/7] phpstan: bump to lvl 7 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 5370ec1..8da2618 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ }, "scripts": { "complete-check": ["@phpstan", "@check-cs", "phpunit"], - "phpstan": "phpstan analyze src --level 5 --configuration phpstan.neon", + "phpstan": "phpstan analyze src --level 7 --configuration phpstan.neon", "check-cs": "easy-coding-standard check src tests", "fix-cs": "easy-coding-standard check src tests --fix" } From 567c039933e178226532e3bcc8118770850676cf Mon Sep 17 00:00:00 2001 From: TomasVotruba Date: Sat, 17 Jun 2017 10:49:26 +0200 Subject: [PATCH 7/7] readme: remove br spaces --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 845c93d..bf7a3cc 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,7 @@ # Object Calisthenics rules for [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) [![Build Status](https://img.shields.io/travis/object-calisthenics/phpcs-calisthenics-rules/master.svg?style=flat-square)](https://travis-ci.org/object-calisthenics/phpcs-calisthenics-rules) - [![Coverage Status](https://img.shields.io/coveralls//object-calisthenics/phpcs-calisthenics-rules/master.svg?style=flat-square)](https://coveralls.io//object-calisthenics/phpcs-calisthenics-rules/Symplify?branch=master) - [![Downloads](https://img.shields.io/packagist/dt/object-calisthenics/phpcs-calisthenics-rules.svg?style=flat-square)](https://packagist.org/packages/object-calisthenics/phpcs-calisthenics-rules) Object Calisthenics are **set of rules in object-oriented code, that focuses of maintainability, readability, testability and comprehensibility**. We're **pragmatic first** - they are easy to use all together or one by one.