All Projects → mnapoli → sniff

mnapoli / sniff

Licence: MIT license
Simpler PHP code sniffer built on top of PHP-CS-Fixer.

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to sniff

php-codesniffer-sniffs
Custom sniffs for PHP_CodeSniffer
Stars: ✭ 16 (+14.29%)
Mutual labels:  coding-standards, php-codesniffer
Codor
Custom PHPCS sniffs to find Code Smells
Stars: ✭ 40 (+185.71%)
Mutual labels:  coding-standards, php-codesniffer
php-cs-fixer-extensions
PHP-CS-Fixer extensions and configurations
Stars: ✭ 71 (+407.14%)
Mutual labels:  coding-standards, php-cs-fixer
wptide
🌊 Tide is a series of automated tests run against every WordPress.org theme and plugin
Stars: ✭ 77 (+450%)
Mutual labels:  coding-standards, php-codesniffer
php-toolbox
🐳 A Docker image designed for PHP developers that care about code quality.
Stars: ✭ 18 (+28.57%)
Mutual labels:  php-cs-fixer, php-codesniffer
phpcs-psr4-sniff
[READ-ONLY] PHP_CodeSniffer sniff that checks class name matches PSR-4 project structure.
Stars: ✭ 23 (+64.29%)
Mutual labels:  coding-standards, php-codesniffer
coding-standard
Consistence - Coding Standard - PHP Code Sniffer rules
Stars: ✭ 73 (+421.43%)
Mutual labels:  coding-standards, php-codesniffer
coding-standard
Nette Coding Standard code checker & fixer
Stars: ✭ 37 (+164.29%)
Mutual labels:  php-cs-fixer
sprint tutorial
Tutorial and mock repository to teach people to contribute to open source
Stars: ✭ 18 (+28.57%)
Mutual labels:  coding-standards
wpcs-docs
WordPress Coding Standards Docs
Stars: ✭ 59 (+321.43%)
Mutual labels:  coding-standards
Twig-CS-Fixer
A tool to automatically fix Twig Coding Standards issues
Stars: ✭ 61 (+335.71%)
Mutual labels:  coding-standards
DebugStatementsFixers
Fixers set for PHP-CS-Fixer. Removes debug statements, which shouldn't be in production ever.
Stars: ✭ 22 (+57.14%)
Mutual labels:  php-cs-fixer
eslint-config
MOXY eslint configuration to be used across several JavaScript projects
Stars: ✭ 14 (+0%)
Mutual labels:  coding-standards
eslint-config-javascript
Write bulletproof JavaScript like a pro! 😎
Stars: ✭ 34 (+142.86%)
Mutual labels:  coding-standards
laravel-php-cs-fixer
A PHP-CS-Fixer bridge for Laravel 5.5+
Stars: ✭ 14 (+0%)
Mutual labels:  php-cs-fixer
PHPCompatibilityWP
PHPCompatibility ruleset for WordPress projects
Stars: ✭ 141 (+907.14%)
Mutual labels:  php-codesniffer
phpcs-gitlab
Gitlab Report for PHP_CodeSniffer (display the violations in the Gitlab CI/CD Code Quality Report)
Stars: ✭ 29 (+107.14%)
Mutual labels:  php-codesniffer
cscs
A curated list of Coding Style Conventions and Standards.
Stars: ✭ 1,486 (+10514.29%)
Mutual labels:  coding-standards
grunt-wp-css
Format style sheets according to the WordPress CSS coding standards.
Stars: ✭ 36 (+157.14%)
Mutual labels:  coding-standards
atom-php-cs-fixer
Run the 'PHP Coding Standards Fixer' within Atom
Stars: ✭ 30 (+114.29%)
Mutual labels:  php-cs-fixer

Sniff

Simpler PHP code sniffer, built on top of PHP-CS-Fixer.

This project has been replaced by Pretty

Build Status

Why?

PHP-CS-Fixer can validate and fix the formatting of your code.

Sniff is a command that wraps php-cs-fixer to make it easier to use and configure.

It boils down to a simple .sniff.json file and 3 commands:

$ sniff validate

Validates that your code complies with your coding standard. Useful in CI to run on each pull request or commit.

$ sniff diff

Validates that your code complies with your coding standard and outputs the diff necessary to fix the errors. Useful to review the fixes before applying them.

$ sniff fix

Fix your code to make it compliant with your coding standard.

Installation

composer require mnapoli/sniff

You can then invoke the command with:

$ vendor/bin/sniff

You can also install it globally with Composer to be able to call it with sniff:

  • composer global require mnapoli/sniff
  • add the ~/.composer/bin path to your PATH

Configuration

Sniff is configured using a .sniff.json file:

{
    "paths": [
        "src",
        "tests"
    ],
    "rules": {
        "@PSR2": true
    },
    "allow-risky": true
}
  • paths (mandatory): list of directories or files to analyze
  • rules (default: @PSR2): list of rules to enable (detailed below)
  • allow-risky (default: no): allows you to set whether risky rules may run (a risky rule is a rule which could change the code's behaviour)

The complete list of rules is detailed in PHP-CS-Fixer's documentation.

Below is an example that enables PSR-2 + Symfony's coding standard, along with a few custom options:

{
    "paths": [ ... ],
    "rules": {
        "@PSR2": true,
        "@Symfony": true,
        "array_syntax": {
            "syntax": "short"
        },
        "blank_line_before_return": false
    }
}

Contributing

To run the tests:

$ composer tests

Credits

This project is only a small wrapper above PHP-CS-Fixer, a huge thanks to the contributors of that tool.

Sniff is heavily inspired from Coke, a nice wrapper for PHP Code Sniffer.

License

Sniff is licensed under the MIT license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].