Skip to content

docs: add Flake8, PHPMD, PHPCS to template & reference (#428) #429

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 2 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
123 changes: 123 additions & 0 deletions docs/reference/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2850,6 +2850,47 @@ ESLint is a static code analysis tool for JavaScript files.

ESLint is a static code analysis tool for JavaScript files.

### Flake8

Flake8 is a static code analysis tool for Python files.

#### Enable Flake8

<Tabs groupId="config-setting">
<TabItem value="web-ui" label="Web UI">
<table>
<tbody>
<tr>
<td><strong>Location</strong></td>
<td>Review &gt; Tools &gt; Flake8 &gt; Enable</td>
</tr>
<tr>
<td><strong>Default</strong></td>
<td>true</td>
</tr>
</tbody></table>
</TabItem>
<TabItem value="yaml" label=".coderabbit.yaml" default>
<table>
<tbody>
<tr>
<td><strong>Field</strong></td>
<td>`reviews.tools.flake8.enabled`</td>
</tr>
<tr>
<td><strong>Datatype</strong></td>
<td>boolean</td>
</tr>
<tr>
<td><strong>Default</strong></td>
<td>true</td>
</tr>
</tbody></table>
</TabItem>
</Tabs>

Flake8 is a static code analysis tool for Python files.

### GitHub Checks

GitHub Checks integration configuration.
Expand Down Expand Up @@ -3708,6 +3749,88 @@ Enable PMD.

Optional path to the PMD configuration file relative to the repository.

### PHPMD

PHPMD is a static code analysis tool for PHP files.

#### Enable PHPMD

<Tabs groupId="config-setting">
<TabItem value="web-ui" label="Web UI">
<table>
<tbody>
<tr>
<td><strong>Location</strong></td>
<td>Review &gt; Tools &gt; Enable PHPMD</td>
</tr>
<tr>
<td><strong>Default</strong></td>
<td>true</td>
</tr>
</tbody></table>
</TabItem>
<TabItem value="yaml" label=".coderabbit.yaml" default>
<table>
<tbody>
<tr>
<td><strong>Field</strong></td>
<td>`reviews.tools.phpmd.enabled`</td>
</tr>
<tr>
<td><strong>Datatype</strong></td>
<td>boolean</td>
</tr>
<tr>
<td><strong>Default</strong></td>
<td>true</td>
</tr>
</tbody></table>
</TabItem>
</Tabs>

PHPMD is a static code analysis tool for PHP files.

### PHPCS

PHPCS is a static code analysis and coding-standard checker for PHP (plus JS/CSS) files.

#### Enable PHPCS

<Tabs groupId="config-setting">
<TabItem value="web-ui" label="Web UI">
<table>
<tbody>
<tr>
<td><strong>Location</strong></td>
<td>Review &gt; Tools &gt; Enable PHPCS</td>
</tr>
<tr>
<td><strong>Default</strong></td>
<td>true</td>
</tr>
</tbody></table>
</TabItem>
<TabItem value="yaml" label=".coderabbit.yaml" default>
<table>
<tbody>
<tr>
<td><strong>Field</strong></td>
<td>`reviews.tools.phpcs.enabled`</td>
</tr>
<tr>
<td><strong>Datatype</strong></td>
<td>boolean</td>
</tr>
<tr>
<td><strong>Default</strong></td>
<td>true</td>
</tr>
</tbody></table>
</TabItem>
</Tabs>

PHPCS is a static code analysis tool for PHP, JavaScript and CSS files.

### Prisma Schema Linting

Configuration for Prisma Schema linting to ensure schema file quality
Expand Down
6 changes: 6 additions & 0 deletions docs/reference/yaml-template.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ reviews:
config_file: ""
eslint:
enabled: true
flake8:
enabled: true
rubocop:
enabled: true
buf:
Expand All @@ -118,6 +120,10 @@ reviews:
pmd:
enabled: true
config_file: ""
phpmd:
enabled: true
phpcs:
enabled: true
cppcheck:
enabled: true
semgrep:
Expand Down
37 changes: 37 additions & 0 deletions docs/tools/flake8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Flake8
sidebar_label: Flake8
description: CodeRabbit's guide to Flake8.
---

```mdx-code-block
import ProPlanNotice from '@site/src/components/ProPlanNotice.mdx';

<ProPlanNotice />
```

[Flake8](https://flake8.pycqa.org/en/latest/) is a static code analysis tool for Python that wraps PyFlakes (error detection), pycodestyle (PEP 8 style rules) and McCabe (cyclomatic-complexity measurement) to catch a wide range of issues in a single pass.

## Supported Files

Flake8 runs on files with the following extension:

- `*.py`

## Features
Flake8 can detect many issues, including:

- PEP 8 style-guide violations
- Unused or re-defined variables and imports
- Undefined names / variables
- Cyclomatic-complexity over threshold (default 10)
- Error-prone constructs (e.g., comparison to literal True / False)
- Select / ignore rule filtering (`--select`, `--extend-ignore`)
- Extensible plugin ecosystem and custom rule support

## Links

- [Flake8 Official Website](https://flake8.pycqa.org/en/latest/)
- [Flake8 PyPI Page](https://pypi.org/project/flake8/)
- [Flake8 GitHub Repository](https://github.com/PyCQA/flake8)
- [User Guide](https://flake8.pycqa.org/en/latest/)