New in Symplify 3: 4 Improvements in EasyCodingStandard

What is new in Easy Coding Standard 3? Nice diffs for fixable sniffs, smart excluding, support for sniff warnings and one more...

1. Exclude Files or Dirs

  Check the PR #583

  Check the PR #584

Do you have src/Migrations that you need to skip from your vendor/bin/ecs check src command?

# easy-coding-standard.neon
        - 'src/Migrations/LastMigration.php'
        # or better all files from the dir
        - '*src/Migrations/*.php'

With favorite fnmatch() function on board.

2. Warnings are Reported for Specific Sniffs

  Check the PR #481

Sniff warnings are skipped by default, because it doesn't make sense to differentiate errors vs warnings. Yet some official Sniffs only produce warnings and that made them useless. Like PHP_CodeSniffer\Standards\Squiz\Sniffs\PHP\CommentedOutCodeSniff.

That changed. New property $reportWarningsSniffs in Symplify\EasyCodingStandard\SniffRunner\File\File now lists all sniffs, that report warnings in ECS as well.

Do you miss useful Sniff that reports only warnings? Send PR to add it.

3. Nice and Clear Diff over Boring Table Report

  Check the PR #474

Inspired by PHP CS Fixer we've decided to use files diffs everywhere wherever it saves user daunting reading.

When a fixable sniff found an error, ECS reported it like this:

 ------ --------------------------------------------------------------------------------------------
  Line   src/Posts/Year2017/Ast/SomeClass.php
 ------ --------------------------------------------------------------------------------------------
  10     Property $someProperty should use doc block instead of one liner

But why bother with such detailed text information, if the ECS will fix it to better form anyway?

From now on, it is reported the PHP CS Fixer-way like all the fixers:

@@ -1,14 +1,13 @@
 final class SomeClass
+    /**
+     * @var SomeType
+     */
-    /** @var SomeType */
     private $someProperty;

    ----------- end diff -----------

Applied checkers:

 - SomeSniff

Which one do you prefer?

4. Skip Sniff Codes instead of Whole Sniffs

  Check the PR #388

If you wanted to skip specific part of sniff, you had to exclude whole sniff via exclude_checkers option:

# easy-coding-standard.neon
        # to skip ".UselessDocComment"
        - SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff

But what if you liked all the other codes?

It's now possible to skip specific sniff codes in skip_codes option:

# easy-coding-standard.neon
        # code to skip for all files
        - SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff.UselessDocComment

And all the other codes will be checked properly in your code.

  Check the PR #406

@ostrolucky took this feature even further and added skipping by list of files or fnmatch.

# easy-coding-standard.neon
        # code to skip for specific files/patterns
            - '*src/Form/Type/*Type.php'

Hope you like the changes and thanks the people who push these tools further by every single PR or issue report!

Happy code fixing!

  Continue Learning

What do you think?

GitHub RSS @votrubaT Runs on Statie Hosted on GitHub

Like what I write about? Hire me & we can work together