Skip to content

Commit 9efbfe8

Browse files
Merge branch 'main' into feature/issue/362
2 parents 080378d + 5b85004 commit 9efbfe8

File tree

10 files changed

+319
-9
lines changed

10 files changed

+319
-9
lines changed

docs/changelog.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,36 @@ description: The latest updates and changes to CodeRabbit.
55
sidebar_position: 13
66
---
77

8+
## July 1, 2025
9+
10+
### Enhanced Code Guidelines Support
11+
12+
We've expanded our code guidelines scanning capabilities to provide even better code review experiences. CodeRabbit now automatically scans and learns from additional configuration files to understand your organization's coding standards and preferences.
13+
14+
**New supported patterns:**
15+
16+
- `**/.cursorrules` - Cursor IDE rules and preferences
17+
- `.github/copilot-instructions.md` - GitHub Copilot instructions
18+
- `**/CLAUDE.md` - Claude-specific coding guidelines
19+
- `**/.cursor/rules/*` - Cursor rules directory
20+
- `**/.windsurfrules` - Windsurf IDE rules
21+
- `**/.clinerules/*` - Cline IDE rules
22+
- `**/.rules/*` - General rules directory
23+
24+
These guidelines are automatically analyzed and applied during code reviews to ensure consistency with your team's coding standards. You can configure these patterns in the knowledge base section of your CodeRabbit settings.
25+
26+
## June 27, 2025
27+
28+
### Enhanced PHP Static Analysis: PHPMD and PHPCS Support
29+
30+
We're excited to announce enhanced PHP static analysis capabilities with two powerful new tools!
31+
32+
- [PHPMD](https://phpmd.org/) (PHP Mess Detector) is a static analysis tool that detects potential problems in your PHP code such as possible bugs, suboptimal code, overcomplicated expressions, and unused parameters, variables, methods, and classes.
33+
34+
- [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) (PHP CodeSniffer) is a development tool that ensures your PHP code conforms to coding standards like PSR-1, PSR-2, PSR-12, and custom standards. It can automatically fix many coding standard violations.
35+
36+
See our [tools documentation](https://docs.coderabbit.ai/tools/) for more details.
37+
838
## June 11, 2025
939

1040
### Enhanced Static Analysis: HTMLHint and Checkmake Support

docs/guides/custom-reports.md

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,166 @@ Issues and tickets brings in conversations, descriptions, and comments from Jira
295295
- `<issue_description>`: markdown - The description of the issue.
296296
- `<issue_comments>`: array of comment objects - Contains all the comments made on the issue.
297297

298+
#### Remove PRs without a "Score Card/Chart" bot comment
299+
300+
This option gives you the ability to create a report limited only to pull requests containing a "Score Card" or "Score Chart" bot comment from CodeRabbit or other bots. To enable issues and tickets you must include the tag `<pr_score_card>` in your prompt.
301+
302+
> **IMPORTANT:** This will automatically remove any pull requests from your reports if they do not contain a "Score Card" or "Score Chart" bot comment. Using this option without setting up a flow to create these comments will result in `No new pull request activity in the last XYZ hours` errors. Do not enable this option unless you have created a "Score Card" or "Score Chart" bot comment flow.
303+
304+
For example you can ask coderabbit to check serveral conditions on a pull request and produce a "Score Chart":
305+
306+
<details>
307+
<summary>Click to view example User Score Card/Chart Comment:</summary>
308+
309+
![Score Card/Chart Trigger Comment Example](/img/guides/score-card-trigger-comment.png)
310+
311+
```markdown
312+
@coderabbitai
313+
Use the <overall_instructions> to guide the content of the summary. Use the format shown in <\_example> but do not include or refer to the example's content in the final summary/report.
314+
315+
<overall_instructions>
316+
317+
**Instructions:**
318+
Generate a weekly code review report for the author of this pull request only following scoring parameters. Calculate the scores and compile the results into a table so that the team-wise average score can be easily determined.
319+
**Scoring Parameters:**
320+
321+
1. **Basic Code Standards (Score out of 2)**
322+
323+
- Avoidance of hard-coded values
324+
- No repetition of code (DRY principle)
325+
326+
2. **Code Readability (Score out of 2)**
327+
328+
- Presence of meaningful comments
329+
- Proper variable declaration using `const` and `let`
330+
331+
3. **Error Handling (Score out of 4)**
332+
333+
- Handling failure scenarios (e.g., try-catch, fallbacks)
334+
- Proper loading state implementation (e.g., button click loading states)
335+
- Handling edge cases (e.g., checking for undefined or missing values)
336+
- Input validation (ensuring correct user inputs)
337+
338+
4. **Circle CI Check Validation (Score: 0 or 1)**
339+
- `0` → Not Passed
340+
- `1` → Passed
341+
342+
**Final Score Calculation:**
343+
Combine the scores from the parameters above to derive the final code quality score (out of 5).
344+
**Output Format:**
345+
Provide the final report in a table format with the following columns (use shorthand notations), be sure to include this list at the top above the chart in the "Column Notation" section so users understand what the columns mean:
346+
347+
- **User Name (User)**
348+
- **Basic Code Standards (BCS) (out of 2)**
349+
- **Code Readability (CR) (out of 2)**
350+
- **Error Handling (EH) (out of 4)**
351+
- **Shopify Theme Check (CI) (out of 1)**
352+
- **Final Code Quality Score (FCQS) (out of 9)**
353+
354+
</overall_instructions>
355+
356+
<\_example>
357+
358+
## Column Notation
359+
360+
- **User Name (User)**
361+
- **Basic Code Standards (BCS) (out of 2)**
362+
- **Code Readability (CR) (out of 2)**
363+
- **Error Handling (EH) (out of 4)**
364+
- **Shopify Theme Check (CI) (out of 1)**
365+
- **Final Code Quality Score (FCQS) (out of 9)**
366+
367+
## Score Chart
368+
369+
| User | BCS (2) | CR (3) | EH (2) | CI (1) | FCQS (9) |
370+
| -------- | ------- | ------ | ------ | ------ | -------- |
371+
| John Doe | 2 | 3 | 2 | 1 | 9 |
372+
373+
</\_example>
374+
```
375+
376+
</details>
377+
378+
Then CodeRabbit will reply with a score for you pull request:
379+
380+
<details>
381+
<summary>Click to view resulting Score Card/Chart bot comment:</summary>
382+
383+
![CodeRabbit Score Card/Chart Result Comment Example](/img/guides/score-card-result-comment.png)
384+
385+
</details>
386+
387+
You can then utilize this in a report. We recommend your report looks specifically for these score cards and puts together a unified report:
388+
389+
<details>
390+
<summary>Click to view example Report Prompt when using Score Card/Chart:</summary>
391+
392+
![Report Example](/img/guides/score-card-report-result.png)
393+
394+
![Where to put this prompt](/img/guides/where-score-report-prompt-go.png)
395+
396+
Prompt Example:
397+
398+
```markdown
399+
Use the <overall_instructions> to guide the content of the summary. Use the format shown in <example> but do not include or refer to the example's content in the final summary/report.
400+
401+
<overall_instructions>
402+
**Instructions:**
403+
404+
Locate the score chart comment in the <bot_comments>. There will be a single comment with data on these fields:
405+
406+
- **User Name (User)**
407+
- **Basic Code Standards (BCS) (out of 2)**
408+
- **Code Readability (CR) (out of 2)**
409+
- **Error Handling (EH) (out of 4)**
410+
- **Shopify Theme Check (CI) (out of 1)**
411+
- **Final Code Quality Score (FCQS) (out of 9)**
412+
413+
These details may also be in the form of a chart such as:
414+
415+
## Score Chart
416+
417+
| User | BCS (2) | CR (3) | EH (2) | CI (1) | FCQS (9) |
418+
| -------- | ------- | ------ | ------ | ------ | -------- |
419+
| John Doe | 2 | 3 | 2 | 1 | 9 |
420+
421+
You will create a new chart averaging all the values from various pull requests for each author. Only include pull requests with a `Score Chart`. Do not invent or create score charts if none exist.
422+
423+
</overall_instructions>
424+
425+
<example>
426+
427+
## Column Notation
428+
429+
- **User Name (User)**
430+
- **Basic Code Standards (BCS) (out of 2)**
431+
- **Code Readability (CR) (out of 2)**
432+
- **Error Handling (EH) (out of 4)**
433+
- **Shopify Theme Check (CI) (out of 1)**
434+
- **Final Code Quality Score (FCQS) (out of 9)**
435+
436+
## Score Chart
437+
438+
| User | BCS (2) | CR (3) | EH (2) | CI (1) | FCQS (9) | PR URL |
439+
| -------- | ------- | ------ | ------ | ------ | -------- | ------ |
440+
| John Doe | 2 | 3 | 2 | 1 | 9 | URL |
441+
| Alex Foo | 2 | 3 | 2 | 1 | 9 | URL |
442+
443+
</example>
444+
<include_bot_comments>
445+
<pr_score_card>
446+
```
447+
448+
</details>
449+
450+
**Best Practices for Score Cards/Charts:**
451+
452+
- The reporting bot only has access to your comments and summary (like a project manager) if you want to make a report looking for these score card/chart comments make sure the reviewer does this ahead of time.
453+
- Only include checks for very specific scenarios, such as a specific check failing or using tabs vs spaces.
454+
- Do not use general rules without explaining specifically what they mean. If you add "Insure the pull request follows development best practices" you must define what "development best practices" actually mean or the AI will guess.
455+
- Make one point for each specific check and make sure its a True/False condition.
456+
- Instead of manually commenting on pull requests you can use the [Github Actions Bot](https://github.com/marketplace/actions/create-or-update-comment) to automatically comment on pull requests and trigger coderabbit score card/chart comments by including `@coderabbit` in the comment.
457+
298458
## Best Practices
299459

300460
1. **Be Specific**

docs/tools/list.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ For an overview of how CodeRabbit uses these tools when generating code reviews,
3232
| Lua | [Luacheck][Luacheck] | Code Quality |
3333
| Makefile | [Checkmake][Checkmake] | Code Quality |
3434
| Markdown | [markdownlint][markdownlint], [LanguageTool][LanguageTool] | Code Quality, Grammar Checking |
35-
| PHP | [PHPStan][PHPStan] | Code Quality |
35+
| PHP | [PHPStan][PHPStan], [PHPMD][PHPMD], [PHPCS][PHPCS] | Code Quality |
3636
| Plaintext | [LanguageTool][LanguageTool] | Grammar and Spell Checking |
3737
| Java | [PMD][PMD] | Code Quality |
3838
| Protobuf | [Buf][Buf] | Code Quality |
@@ -84,3 +84,5 @@ For an overview of how CodeRabbit uses these tools when generating code reviews,
8484
[DotenvLinter]: /tools/dotenv.md
8585
[HTMLHint]: /tools/htmlhint.md
8686
[Checkmake]: /tools/checkmake.md
87+
[PHPMD]: /tools/phpmd.md
88+
[PHPCS]: /tools/phpcs.md

docs/tools/phpcs.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: PHPCS
3+
sidebar_label: PHPCS
4+
description: CodeRabbit's guide to PHPCS.
5+
---
6+
7+
```mdx-code-block
8+
import ProPlanNotice from '@site/src/components/ProPlanNotice.mdx';
9+
10+
<ProPlanNotice />
11+
```
12+
13+
[PHPCS](https://github.com/squizlabs/PHP_CodeSniffer) (PHP CodeSniffer) is a development tool that ensures your code conforms to a coding standard. It is an essential tool for any development team that wants to ensure their code is consistent and follows best practices.
14+
15+
## Files
16+
17+
PHPCS will run on files with the following extensions:
18+
19+
- `.php`
20+
21+
## Features
22+
23+
PHPCS can detect and fix various coding standard violations including:
24+
25+
- **PSR Standards**: Enforces PSR-1, PSR-2, PSR-12, and other coding standards
26+
- **Custom Standards**: Supports custom coding standards and rules
27+
- **Auto-fixing**: Can automatically fix many coding standard violations
28+
- **Custom Rules**: Allows creation of custom sniff rules
29+
- **Multiple Standards**: Can enforce multiple coding standards simultaneously
30+
31+
## Popular Standards
32+
33+
PHPCS supports many coding standards including:
34+
35+
- **PSR-1**: Basic Coding Standard
36+
- **PSR-2**: Coding Style Guide
37+
- **PSR-12**: Extended Coding Style
38+
- **Squiz**: Squiz Labs coding standard
39+
- **PEAR**: PEAR coding standard
40+
- **Zend**: Zend Framework coding standard
41+
42+
## Configuration
43+
44+
PHPCS requires a configuration file to run. CodeRabbit will only run PHPCS if one of the following configuration files is found:
45+
46+
- `phpcs.xml` - XML configuration file
47+
- `phpcs.xml.dist` - Distributed XML configuration file
48+
49+
CodeRabbit will not run PHPCS if no configuration file is found.
50+
51+
## Links
52+
53+
- [PHPCS GitHub Repository](https://github.com/squizlabs/PHP_CodeSniffer)
54+
- [PHPCS Documentation](https://github.com/squizlabs/PHP_CodeSniffer/wiki)
55+
- [Available Coding Standards](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standards)
56+
- [Creating Custom Standards](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Coding-Standards#creating-a-coding-standard)

docs/tools/phpmd.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
title: PHPMD
3+
sidebar_label: PHPMD
4+
description: CodeRabbit's guide to PHPMD.
5+
---
6+
7+
```mdx-code-block
8+
import ProPlanNotice from '@site/src/components/ProPlanNotice.mdx';
9+
10+
<ProPlanNotice />
11+
```
12+
13+
[PHPMD](https://phpmd.org/) (PHP Mess Detector) is a static analysis tool for PHP that detects potential problems in your code such as possible bugs, suboptimal code, overcomplicated expressions, and unused parameters, variables, methods, and classes.
14+
15+
## Files
16+
17+
PHPMD will run on files with the following extensions:
18+
19+
- `.php`
20+
21+
## Features
22+
23+
PHPMD can detect various code quality issues including:
24+
25+
- **Clean Code Rules**: Detects code smells and violations of clean code principles
26+
- **Controversial Rules**: Identifies potentially problematic code patterns
27+
- **Design Rules**: Finds design-related issues and architectural problems
28+
- **Naming Rules**: Checks for naming convention violations
29+
- **Unused Code Rules**: Detects unused variables, parameters, methods, and classes
30+
- **Size Rules**: Identifies overly complex methods and classes
31+
32+
### Review Mode Behavior
33+
34+
CodeRabbit's review mode affects which PHPMD rules are applied:
35+
36+
- **Chill Mode**: Only checks for unused code (`unusedcode` rule set)
37+
- **Nitpick Mode**: Checks all rule sets including clean code, code size, controversial rules, design issues, naming conventions, and unused code (`cleancode,codesize,controversial,design,naming,unusedcode`)
38+
39+
## Links
40+
41+
- [PHPMD Official Website](https://phpmd.org/)
42+
- [PHPMD GitHub Repository](https://github.com/phpmd/phpmd)
43+
- [PHPMD Documentation](https://phpmd.org/documentation/index.html)
44+
- [Available Rules](https://phpmd.org/rules/index.html)
69.9 KB
Loading
95.3 KB
Loading
86.2 KB
Loading
Loading

static/schema/schema.v2.json

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,32 @@
604604
"default": {},
605605
"description": "PHPStan is a tool to analyze PHP code."
606606
},
607+
"phpmd": {
608+
"type": "object",
609+
"properties": {
610+
"enabled": {
611+
"type": "boolean",
612+
"default": true,
613+
"description": "Enable PHPMD | PHPMD is a tool to find potential problems in PHP code. | v2.15.0"
614+
}
615+
},
616+
"additionalProperties": false,
617+
"default": {},
618+
"description": "PHPMD is a tool to find potential problems in PHP code."
619+
},
620+
"phpcs": {
621+
"type": "object",
622+
"properties": {
623+
"enabled": {
624+
"type": "boolean",
625+
"default": true,
626+
"description": "Enable PHP CodeSniffer | PHP CodeSniffer is a PHP linter and coding standard checker. | v3.7.2"
627+
}
628+
},
629+
"additionalProperties": false,
630+
"default": {},
631+
"description": "PHP CodeSniffer is a PHP linter and coding standard checker."
632+
},
607633
"golangci-lint": {
608634
"type": "object",
609635
"properties": {
@@ -697,10 +723,6 @@
697723
"type": "boolean",
698724
"default": true,
699725
"description": "Enable Flake8 | Flake8 is a Python linter that wraps PyFlakes, pycodestyle and Ned Batchelder's McCabe script. | v7.2.0"
700-
},
701-
"config_file": {
702-
"type": "string",
703-
"description": "Optional path to the Flake8 configuration file relative to the repository. This is useful when the configuration file is named differently than the default '.flake8' or 'setup.cfg'."
704726
}
705727
},
706728
"additionalProperties": false,
@@ -943,10 +965,6 @@
943965
"type": "boolean",
944966
"default": true,
945967
"description": "Enable HTMLHint | HTMLHint is a static code analysis tool for HTML files. | Enable HTMLHint integration. | v1.5.0"
946-
},
947-
"config_file": {
948-
"type": "string",
949-
"description": "Optional path to the HTMLHint configuration file relative to the repository. This is useful when the configuration file is named differently than the default '.htmlhintrc'."
950968
}
951969
},
952970
"additionalProperties": false,

0 commit comments

Comments
 (0)