Skip to content

Commit

Permalink
Merge pull request #65 from object-calisthenics/polishing
Browse files Browse the repository at this point in the history
Polishing before release
  • Loading branch information
Tomáš Votruba committed Jun 17, 2017
2 parents 2aaf984 + 567c039 commit 37d1c2e
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 32 deletions.
3 changes: 3 additions & 0 deletions .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
3 changes: 2 additions & 1 deletion .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
2 changes: 0 additions & 2 deletions .scrutinizer.yml

This file was deleted.

8 changes: 4 additions & 4 deletions .travis.yml
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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.
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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"
}
Expand Down
9 changes: 6 additions & 3 deletions easy-coding-standard.neon
Expand Up @@ -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
Expand Down
Expand Up @@ -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);
}
}
Expand Down
20 changes: 4 additions & 16 deletions tests/FileFactory.php
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
}
}
2 changes: 1 addition & 1 deletion tests/Helper/ClassAnalyzerTest.php
Expand Up @@ -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');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/NamingTest.php
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/Helper/Structure/StructureMetricsTest.php
Expand Up @@ -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
Expand Down

0 comments on commit 37d1c2e

Please sign in to comment.