Skip to content

Add new Sniff to check declare statements #179

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions BigBite/Docs/Files/DeclareStatementStandard.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<documentation title="Declare Statements">
<standard>
<![CDATA[
Declare statements should be formatted in the following way:
- the declare keyword should be lower case
- no space between the keyword and opening parenthesis
- one space after the opening parenthesis
- one space before the equals sign
- one space after the equals sign
- one space before the closing parenthesis
- no space between the closing parenthesis and terminating semi-colon
- one space between the closing parenthesis and opening curly brace in a block declaration
- the opening curly brace should be the last content on the line
- the closing curly brace in a block declaration should be on a new line
- the closing curly brace should be column-aligned with the declare keyword
- the only supported directives are "ticks", "strict_types", or "encoding"
]]>
</standard>
<code_comparison>
<code title="Valid: Correct spacing.">
<![CDATA[
declare<em></em>(<em> </em>strict_types<em> </em>=<em> </em>1<em> </em>)<em></em>;
declare(<em> </em>strict_types = 1<em> </em>);


]]>
</code>
<code title="Invalid: Incorrect spacing.">
<![CDATA[
declare<em> </em>(<em></em>strict_types<em> </em>=<em></em>1<em></em>)<em> </em>;
declare(<em>
</em>strict_types = 1<em>
</em>);
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Correct directive.">
<![CDATA[
declare( <em>strict_types</em> = 1 );
]]>
</code>
<code title="Invalid: Invalid directive.">
<![CDATA[
declare( <em>struct_types</em> = 1 );
]]>
</code>
</code_comparison>
<code_comparison>
<code title="Valid: Correct braces spacing and alignment in block declaration.">
<![CDATA[
declare( ticks = 1 )<em> </em>{
// code here.
<em></em>}
]]>
</code>
<code title="Invalid: Incorrect braces spacing and alignment in block declaration.">
<![CDATA[
declare( ticks = 1 )<em> </em>{
// code here.
<em> </em>}
]]>
</code>
</code_comparison>
</documentation>
Loading