2017 © Pedro Peláez
 

phpcodesniffer-standard coding-standard

Keboola coding standard

image

keboola/coding-standard

Keboola coding standard

  • Saturday, May 19, 2018
  • by tomasfejfar
  • Repository
  • 7 Watchers
  • 0 Stars
  • 2,400 Installations
  • Shell
  • 7 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 10 Versions
  • 48 % Grown

The README.md

Keboola Coding Standard

Versioning

  • patch versions may only weaken the checks if a bug in a sniff is found
  • minor versions may only update underlying coding standards with bugfixes
  • major versions may introduce new sniffs, thus causing previously good builds to fail

So you should be usually fine with composer's default ^major.minor, (*1)

Installation

  • install via composer
composer require --dev keboola/coding-standard
  • copy example/phpcs.xml to your project root directory.
  • now you can check your src and tests directory using
vendor/bin/phpcs src tests
  • add phpcs script to composer.json
{
...
    "scripts": {
        "phpcs": "phpcs -n --extensions=php ."
    }
}

Usage

composer phpcs, (*2)

Using standard on legacy projects

If fixing the violations is too complex, you can exclude the respective sniffs., (*3)

First you need to know which sniff is causing the violation., (*4)

composer phpcs -- -s

This will dump the sniff name along with the violation., (*5)

phpcs -n --extensions=php . "-s"

FILE: W:\keboola\http-extractor\src\Config.php
----------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
----------------------------------------------------------------------
 11 | ERROR | Method \Keboola\HttpExtractor\Config::getBaseUrl() does not
    |       | have return type hint nor @return annotation for its return
    |       | value.
    |       | (SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint)
----------------------------------------------------------------------

Then add the sniff to excludes in your phpcs.xml, (*6)

<?xml version="1.0"?>
<ruleset name="Custom">
    <rule ref="vendor/keboola/coding-standard/ruleset.xml">
        <exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint" />
    </rule>
</ruleset>

Repeat until there are no violations., (*7)

You may take note of fixable violations and separate them visually in the file, possibly with <!-- Fixable violations below -->. That way anyone can remove one exclusion at a time, let phpcbf fix the violation, review the result and submit a PR with a fix. This will improve the chances of fixing the violations in the future., (*8)

License

MIT licensed, see LICENSE file., (*9)

The Versions

19/05 2018

dev-tf2-dummy-comments-fix

dev-tf2-dummy-comments-fix

Keboola coding standard

  Sources   Download

MIT

The Requires

 

19/05 2018

dev-tf2-update-deps

dev-tf2-update-deps

Keboola coding standard

  Sources   Download

MIT

The Requires

 

15/05 2018

dev-tf2-dummy-comments

dev-tf2-dummy-comments

Keboola coding standard

  Sources   Download

MIT

The Requires

 

15/05 2018

dev-master

9999999-dev

Keboola coding standard

  Sources   Download

MIT

The Requires

 

15/05 2018

4.0.0

4.0.0.0

Keboola coding standard

  Sources   Download

MIT

The Requires

 

14/05 2018

3.0.0

3.0.0.0

Keboola coding standard

  Sources   Download

MIT

The Requires

 

04/04 2018

2.0.0

2.0.0.0

Keboola coding standard

  Sources   Download

MIT

The Requires

 

04/04 2018

dev-tf-space-after-cast-sniff

dev-tf-space-after-cast-sniff

Keboola coding standard

  Sources   Download

MIT

The Requires

 

27/03 2018

dev-tf2-build

dev-tf2-build

Keboola coding standard

  Sources   Download

MIT

The Requires

 

26/03 2018

1.0.0

1.0.0.0

Keboola coding standard

  Sources   Download

MIT

The Requires