Skip to content

Preview/phpcs #55

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
3 changes: 3 additions & 0 deletions .coderabbit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
reviews:
profile: "assertive"
path_filters: ["**/*","*.*"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix YAML formatting issues.

The static analysis tool has identified formatting issues that should be addressed:

  1. Missing space after comma in the array
  2. Missing newline at end of file

Apply this diff to fix the formatting:

-  path_filters: ["**/*","*.*"]
+  path_filters: ["**/*", "*.*"]
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
path_filters: ["**/*","*.*"]
path_filters: ["**/*", "*.*"]
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 3-3: too few spaces after comma

(commas)


[error] 3-3: no new line character at the end of file

(new-line-at-end-of-file)

🤖 Prompt for AI Agents
In .coderabbit.yml at line 3, fix the YAML formatting by adding a space after
the comma in the path_filters array and ensure there is a newline at the end of
the file. This will correct the spacing issue and comply with YAML formatting
standards.

10 changes: 10 additions & 0 deletions bad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

class MyCalculator
{
public function add($a, $b)
{
$result = $a + $b
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix syntax error: missing semicolon.

There is a syntax error on line 7 where the semicolon is missing after the addition operation. This will prevent the code from executing.

Apply this diff to fix the syntax error:

-        $result = $a + $b
+        $result = $a + $b;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$result = $a + $b
$result = $a + $b;
🧰 Tools
🪛 phpcs (3.7.2)

[ERROR] 7-7: Tabs must be used to indent lines; spaces are not allowed

(Generic.WhiteSpace.DisallowSpaceIndent.SpacesUsed)


[ERROR] 7-7: Operation must be bracketed

(Squiz.Formatting.OperatorBracket.MissingBrackets)

🤖 Prompt for AI Agents
In bad.php at line 7, there is a missing semicolon at the end of the statement
assigning $result. Add a semicolon after "$a + $b" to fix the syntax error and
allow the code to execute properly.

return $result;
}
}
47 changes: 47 additions & 0 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0"?>
<ruleset name="Strictest Coding Standards">

<!-- Description -->
<description>
Enforces strict coding standards by combining multiple standards and custom rules.
</description>

<!-- Directories and file patterns to ignore -->
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>node_modules/*</exclude-pattern>
<exclude-pattern>storage/*</exclude-pattern>
<exclude-pattern>cache/*</exclude-pattern>
<exclude-pattern>*.min.js</exclude-pattern>

<!-- Rulesets to use (add/remove as needed) -->
<rule ref="PSR12"/>
<rule ref="Squiz"/>
<rule ref="Generic"/>
<rule ref="PEAR"/>
<rule ref="Zend"/>
<rule ref="MySource"/>
<rule ref="PSR1"/>

<!-- Optionally enable some stricter rules -->
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.Formatting.SpaceAfterNot"/>
<rule ref="Squiz.Functions.GlobalFunction"/>
<rule ref="Squiz.Functions.FunctionDuplicateArgument"/>
<rule ref="Squiz.Scope.MethodScope"/>
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
<rule ref="Generic.PHP.ForbiddenFunctions"/>
<rule ref="Generic.CodeAnalysis.ForLoopShouldBeWhileLoop"/>

<!-- Report errors as warnings for visibility, or adjust as needed -->
<arg name="report" value="full"/>
<arg name="colors"/>
<arg name="encoding" value="utf-8"/>

<!-- Extensions to check -->
<fileExtensions>
<extension>php</extension>
<extension>inc</extension>
<extension>phtml</extension>
</fileExtensions>

</ruleset>