Skip to content

Commit

Permalink
fix: ignore incorrect whitespace before declare error
Browse files Browse the repository at this point in the history
  • Loading branch information
ramsey committed Jul 1, 2021
1 parent b9795c9 commit c0d3cd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## 2.0.1 - 2021-06-30

### Fixed

* Ignore the `IncorrectWhitespaceBeforeDeclare` error emitted by the `SlevomatCodingStandard.TypeHints.DeclareStrictTypes` sniff.

In my personal projects, I usually have 2 newlines before the `declare` statement. One before the file header comment and one after. However, in tests, I have no file header comment, so there is only 1 newline before the `declare` statement. Since I like my tests to follow the same coding standard as the rest of my source, it is easiest to ignore this error.


## 2.0.0 - 2021-06-30

### Added
Expand Down
12 changes: 7 additions & 5 deletions src/Ramsey/ruleset.xml
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,14 @@

<!-- Require presence of declare(strict_types=1) -->
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<!-- Ignore whitespace requirements for lines occurring before declare(strict_types=1).
In general, we have two lines before this statement, one before the
file header comment and one after. The sniff does not count any
newlines from the comment block. However, in tests, we don't use
file header comments, so we have only one line before this
statement. This causes problems, so we just ignore this error. -->
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes.IncorrectWhitespaceBeforeDeclare"/>
<properties>
<!--
Two newlines accounts for 1 newline, the file header comment,
and 1 more newline before declare(strict_types=1).
-->
<property name="linesCountBeforeDeclare" value="2"/>
<property name="linesCountAfterDeclare" value="1"/>
<property name="spacesCountAroundEqualsSign" value="0"/>
</properties>
Expand Down

0 comments on commit c0d3cd8

Please sign in to comment.