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..31098ec 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,14 +20,14 @@ 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 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..bf7a3cc 100644 --- a/README.md +++ b/README.md @@ -1,7 +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) -[![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. 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" } 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/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); } } diff --git a/tests/FileFactory.php b/tests/FileFactory.php index 6d32108..367af86 100644 --- a/tests/FileFactory.php +++ b/tests/FileFactory.php @@ -20,13 +20,13 @@ public function __construct() // initialize Token constants if (! defined('T_NONE')) { - new Tokens(); + new Tokens; } } 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); } } 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