Skip to content

Add linter documentation #59

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

Merged
merged 13 commits into from
Jul 15, 2024
Merged
Changes from 12 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
2 changes: 1 addition & 1 deletion docs/guides/commands.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@ sidebar_label: CodeRabbit Commands
description:
CodeRabbit offers various commands that can be invoked as PR comments to
control the review process.
sidebar_position: 3
sidebar_position: 4
---

The following commands are available (invoked as PR comments):
2 changes: 1 addition & 1 deletion docs/guides/delete-account.md
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
title: Delete CodeRabbit Account
sidebar_label: Delete CodeRabbit Account
# description:
sidebar_position: 3
sidebar_position: 5
---

The guide explains how to delete your CodeRabbit account and all the data
3 changes: 1 addition & 2 deletions docs/guides/ondemand-reports.md
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ title: On-demand Reports
sidebar_label: On-demand Reports (Beta)
description:
CodeRabbit offers a way to generate on-demand reports using a simple API request
sidebar_position: 5
sidebar_position: 6
---

```mdx-code-block
@@ -54,7 +54,6 @@ Sample output:
]
```


:::info

If you get a 401 UNAUTHORIZED error, check if you're passing the right API key in the `x-coderabbitai-api-key` header
2 changes: 1 addition & 1 deletion docs/guides/review-instructions.md
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ description:
CodeRabbit offers various customization options to tailor the reviews to your
specific requirements. Customizations can be made using one of the below
options.
sidebar_position: 2
sidebar_position: 3
---

The guide explains how to add custom review instructions for the entire project.
4 changes: 4 additions & 0 deletions docs/guides/tools/_category_.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
label: Tools
position: 2
collapsible: true
collapsed: true
198 changes: 198 additions & 0 deletions docs/guides/tools/biome.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
---
title: Biome
sidebar_label: Biome
description: CodeRabbit's guide to Biome.
sidebar_position: 5
---

[Biome](https://biomejs.dev/) is a linter for JavaScript, TypeScript, JSX, TSX, JSON, JSONC, CSS.

## Files

Biome will run on files with the following extensions:

- `.js`
- `.ts`
- `.cjs`
- `.mjs`
- `.d.cts`
- `.d.mts`
- `.jsx`
- `.tsx`
- `.json`
- `.jsonc`
- `.css`

## Configuration

Biome supports the following config files:

- `biome.jsonc`
- `biome.json`

CodeRabbit will use the following settings based on the profile selected if no config file is found:

### Chill

```json
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"all": false,
"recommended": true,
"a11y": {
"recommended": false
},
"correctness": {
"useExhaustiveDependencies": "off",
"noInnerDeclarations": "off"
},
"style": {
"recommended": false,
"noArguments": "warn",
"noCommaOperator": "warn",
"noUselessElse": "warn",
"useAsConstAssertion": "off",
"useBlockStatements": "off",
"useConsistentArrayType": "off",
"useDefaultParameterLast": "warn",
"useEnumInitializers": "off",
"useExponentiationOperator": "warn",
"useExportType": "off",
"useFragmentSyntax": "off",
"useImportType": "off",
"useLiteralEnumMembers": "warn",
"useShorthandArrayType": "off",
"noUnusedTemplateLiteral": "off"
},
"complexity": {
"noForEach": "off",
"noExcessiveCognitiveComplexity": {
"level": "off",
"options": {
"maxAllowedComplexity": 25
}
},
"useLiteralKeys": "off",
"useArrowFunction": "off",
"useFlatMap": "off"
},
"suspicious": {
"noArrayIndexKey": "off",
"noExplicitAny": "off",
"noImplicitAnyLet": "off",
"noDoubleEquals": "off"
},
"nursery": {
"all": false
}
}
},
"css": {
"linter": {
"enabled": true
},
"parser": {
"cssModules": true
}
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
}
}
```

### Assertive

```json
{
"$schema": "https://biomejs.dev/schemas/1.8.3/schema.json",
"organizeImports": {
"enabled": false
},
"formatter": {
"enabled": false
},
"linter": {
"enabled": true,
"rules": {
"all": false,
"recommended": true,
"a11y": {
"recommended": ""
},
"correctness": {
"useExhaustiveDependencies": "off",
"noInnerDeclarations": "warn"
},
"style": {
"recommended": true,
"noArguments": "warn",
"noCommaOperator": "warn",
"noUselessElse": "warn",
"useAsConstAssertion": "off",
"useBlockStatements": "off",
"useConsistentArrayType": "off",
"useDefaultParameterLast": "warn",
"useEnumInitializers": "off",
"useExponentiationOperator": "warn",
"useExportType": "off",
"useFragmentSyntax": "off",
"useImportType": "off",
"useLiteralEnumMembers": "warn",
"useShorthandArrayType": "off",
"noUnusedTemplateLiteral": "off"
},
"complexity": {
"noForEach": "off",
"noExcessiveCognitiveComplexity": {
"level": "warn",
"options": {
"maxAllowedComplexity": 25
}
},
"useLiteralKeys": "off",
"useArrowFunction": "",
"useFlatMap": ""
},
"suspicious": {
"noArrayIndexKey": "",
"noExplicitAny": "",
"noImplicitAnyLet": "",
"noDoubleEquals": ""
},
"nursery": {
"all": false
}
}
},
"css": {
"linter": {
"enabled": true
},
"parser": {
"cssModules": true
}
},
"javascript": {
"parser": {
"unsafeParameterDecoratorsEnabled": true
}
}
}

```

## Links

- [Biome Configuration](https://biomejs.dev/reference/configuration/)
29 changes: 29 additions & 0 deletions docs/guides/tools/golangci-lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: golangci-lint
sidebar_label: golangci-lint
description: CodeRabbit's guide to golangci-lint.
sidebar_position: 8
---

[golangci-lint](https://golangci-lint.run/) is a fast Go linters runner.

## Files

golangci-lint will run on files with the following extensions:

- `.go`
- `go.mod`

## Configuration

golangci-lint supports the following config files:

- User-defined config file set at `reviews.tools.golangci-lint.config_file` in your project's `.coderabbit.yaml` file or setting the "Review → Tools → golangci-lint → Config File" field in CodeRabbit's settings page.
- `.golangci.yml`
- `.golangci.yaml`
- `.golangci.toml`
- `.golangci.json`

## Links

- [golangci-lint Configuration](https://golangci-lint.run/usage/configuration/)
42 changes: 42 additions & 0 deletions docs/guides/tools/hadolint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
title: Hadolint
sidebar_label: Hadolint
description: CodeRabbit's guide to Hadolint.
sidebar_position: 6
---

[Hadolint](https://github.com/hadolint/hadolint) is a Dockerfile linter.

## Files

Hadolint will run on files with the following file names:

- `Dockerfile`
- `*.dockerfile`
- `Dockerfile.*`

## Configuration

Hadolint supports the following config files:

- `.hadolint.yaml`

CodeRabbit will ignore the following severity levels if no config file is found:

### Chill

- `none`
- `ignore`
- `style`
- `info`
- `warning`

### Assertive

- `none`
- `ignore`
- `style`

## Links

- [Hadolint Configuration](https://github.com/hadolint/hadolint?tab=readme-ov-file#configure)
37 changes: 37 additions & 0 deletions docs/guides/tools/languagetool.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: LanguageTool
sidebar_label: LanguageTool
description: CodeRabbit's guide to LanguageTool.
sidebar_position: 4
---

[LanguageTool](https://github.com/languagetool-org/languagetool) is a style and grammar checker.

## Files

LanguageTool will run on files with the following extensions:

- `.md`
- `.mdx`
- `.markdown`
- `.txt`

## Configuration

LanguageTool's style and grammar check depends on the language selected in CodeRabbit's configuration. You can set the language by setting the `language` field in your project's `.coderabbit.yaml` file or setting the "Review Language" field in CodeRabbit's settings page.

CodeRabbit allows further configuring LanguageTool by setting specific rules and categories to be enabled/disabled. This can be done under the `reviews.tools.languagetool` field in your project's `.coderabbit.yaml` file or setting the various options under "Review → Tools → LanguageTool" in CodeRabbit's settings page. The following options are available:

- `enabled` - Enable or disable LanguageTool.
- `enabled_rules` - Enable specific rules.
- `disabled_rules` - Disable specific rules.
- `enabled_categories` - Enable specific categories.
- `disabled_categories` - Disable specific categories.
- `enabled_only`- Enable only the rules and categories of IDs are specified with 'enabledRules' or 'enabledCategories'.
- `level` - Set the level of feedback to be provided by LanguageTool. The following levels are available:
- `default` - Provides feedback on common issues.
- `picky` - Provides feedback on more issues, rules that you might only find useful when checking formal text.

## Links

- [LanguageTool Rules](https://community.languagetool.org/rule/list?lang=en)
75 changes: 75 additions & 0 deletions docs/guides/tools/markdownlint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
title: Markdownlint
sidebar_label: Markdownlint
description: CodeRabbit's guide to Markdownlint.
sidebar_position: 3
---

[Markdownlint](https://github.com/DavidAnson/markdownlint) is a linter for Markdown.

## Files

Markdownlint will run on files with the following extensions:

- `.md`
- `.markdown`

## Configuration

Markdownlint supports the following config files:

- `.markdownlint.jsonc`
- `.markdownlint.json`
- `.markdownlint.yaml`
- `.markdownlint.yml`

CodeRabbit will use the following settings based on the profile selected if no config file is found:

### Chill

```json
{
"default": true,
"line-length": false,
"no-duplicate-heading": {
"siblings_only": true
},
"no-trailing-punctuation": {
"punctuation": ".,;:"
},
"ol-prefix": false,
"list-marker-space": false,
"no-inline-html": false,
"first-line-h1": false,
"no-trailing-spaces": false,
"single-h1": false,
"blank_lines": false,
}
```

### Assertive

```json
{
"default": true,
"line-length": false,
"no-duplicate-heading": {
"siblings_only": true
},
"no-trailing-punctuation": {
"punctuation": ".,;:"
},
"ol-prefix": true,
"list-marker-space": false,
"no-inline-html": true,
"first-line-h1": true,
"no-trailing-spaces": true,
"single-h1": true,
"blank_lines": true,
}

```

## Links

- [Markdownlint Configuration](https://github.com/DavidAnson/markdownlint?tab=readme-ov-file#configuration)
28 changes: 28 additions & 0 deletions docs/guides/tools/phpstan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
title: PHPStan
sidebar_label: PHPStan
description: CodeRabbit's guide to PHPStan.
sidebar_position: 8
---

[PHPStan](https://phpstan.org/) is a static analysis tool for PHP.

## Files

PHPStan will run on files with the following extensions:

- `.php`

## Configuration

PHPStan supports the following config files:

- `phpstan.neon`
- `phpstan.neon.dist`
- `phpstan.dist.neon`

CodeRabbit will not run PHPStan if no config file is found.

## Links

- [PHPStan Configuration](https://phpstan.org/config-reference)
128 changes: 128 additions & 0 deletions docs/guides/tools/ruff.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
title: Ruff
sidebar_label: Ruff
description: CodeRabbit's guide to Ruff.
sidebar_position: 2
---

[Ruff](https://docs.astral.sh/ruff/) is a linter for Python.

## Files

Ruff will run on files with the following extensions:

- `.py`

## Configuration

Ruff supports the following config files:

- `pyproject.toml`
- `ruff.toml`
- `.ruff.toml`

CodeRabbit will use the following settings based on the profile selected if no config file is found:

### Chill

```toml
[lint]
select = [
# pycodestyle subset rules
"E7",
"E9",
# Pyflakes
"F",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort subset rules
"I002",
]
[lint.per-file-ignores]
"**/__init__.py" = ["E402"]
"**/conftest.py" = ["E402"]
```

### Assertive

```toml
[lint]
select = [
# pycodestyle subset rules
"E7",
"E9",
# Pyflakes
"F",
# flake8-bugbear
"B",
# flake8-simplify
"SIM",
# isort subset rules
"I002",
# pycodestyle subset rules
"E4",
"E101",
# mccabe
"C90",
# flake8-annotations
"ANN",
# flake8-async
"ASYNC",
# flake8-trio
"TRIO",
# flake8-bandit
"S",
# flake8-blind-except
"BLE",
# flake8-boolean-trap
"FBT",
# flake8-commas
"COM",
# flake8-comprehensions
"C4",
# flake8-datetimez
"DTZ",
# flake8-debugger
"T10",
# flake8-django
"DJ",
# flake8-executable
"EXE",
# flake8-implicit-str-concat
"ISC",
# flake8-logging
"LOG",
# flake8-logging-format
"G",
# flake8-pie
"PIE",
# flake8-pytest-style
"PT",
# flake8-raise
"RSE",
# flake8-return
"RET",
# flake8-unused-arguments
"ARG",
# tryceratops
"TRY",
# flynt
"FLY",
# Ruff-specific rules
"RUF",
# pyupgrade
"UP",
]
[lint.per-file-ignores]
"**/__init__.py" = ["E402"]
"**/conftest.py" = ["E402"]
"**/*_test.py" = ["S101"]
"**/test_*.py" = ["S101"]
"**/{test,tests}/**/*.py" = ["S101"]
```

## Links

- [Ruff Configuration](https://docs.astral.sh/ruff/configuration/)
37 changes: 37 additions & 0 deletions docs/guides/tools/shellcheck.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: ShellCheck
sidebar_label: ShellCheck
description: CodeRabbit's guide to ShellCheck.
sidebar_position: 1
---

[ShellCheck](https://www.shellcheck.net/) is a linter for shell scripts.

## Files

ShellCheck will run on files with the following extensions:

- `.sh`
- `.bash`
- `.ksh`
- `.dash`

## Configuration

CodeRabbit will use the following settings based on the profile selected:

### Chill

```shell
--severity=warning
```

### Assertive

```shell
--severity=style
```

## Links

- [ShellCheck Wiki](https://www.shellcheck.net/wiki/)
117 changes: 117 additions & 0 deletions docs/guides/tools/swiftlint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
title: SwiftLint
sidebar_label: SwiftLint
description: CodeRabbit's guide to SwiftLint.
sidebar_position: 7
---

[SwiftLint](https://realm.github.io/SwiftLint/) is a linter for Swift.

## Files

SwiftLint will run on files with the following extensions:

- `.swift`

## Configuration

Ruff supports the following config files:

- User-defined config file set at `reviews.tools.swiftlint.config_file` in your project's `.coderabbit.yaml` file or setting the "Review → Tools → SwiftLint → Config File" field in CodeRabbit's settings page.
- `.swiftlint.yaml`
- `.swiftlint.yml`

CodeRabbit will use the following settings if no config file is found:

```yaml
disabled_rules:
- closure_body_length
- cyclomatic_complexity
- enum_case_associated_values_count
- file_length
- function_body_length
- function_parameter_count
- large_tuple
- line_length
- nesting
- type_body_length
- attributes
- closing_brace
- closure_end_indentation
- closure_parameter_position
- closure_spacing
- collection_alignment
- colon
- comma
- comma_inheritance
- computed_accessors_order
- conditional_returns_on_newline
- control_statement
- custom_rules
- direct_return
- empty_enum_arguments
- empty_parameters
- empty_parentheses_with_trailing_closure
- explicit_self
- file_header
- file_types_order
- identifier_name
- implicit_getter
- implicit_return
- inclusive_language
- indentation_width
- leading_whitespace
- let_var_whitespace
- literal_expression_end_indentation
- modifier_order
- multiline_arguments
- multiline_arguments_brackets
- multiline_function_chains
- multiline_literal_brackets
- multiline_parameters
- multiline_parameters_brackets
- multiple_closures_with_trailing_closure
- no_space_in_method_call
- non_overridable_class_declaration
- number_separator
- opening_brace
- operator_usage_whitespace
- operator_whitespace
- optional_enum_case_matching
- period_spacing
- prefer_self_in_static_references
- prefer_self_type_over_type_of_self
- prefixed_toplevel_constant
- protocol_property_accessors_order
- redundant_discardable_let
- redundant_self_in_closure
- return_arrow_whitespace
- self_binding
- shorthand_argument
- shorthand_operator
- single_test_class
- sorted_enum_cases
- sorted_imports
- statement_position
- superfluous_else
- switch_case_alignment
- switch_case_on_newline
- trailing_closure
- trailing_comma
- trailing_newline
- trailing_whitespace
- type_contents_order
- unneeded_parentheses_in_closure_argument
- unused_optional_binding
- vertical_parameter_alignment
- vertical_parameter_alignment_on_call
- vertical_whitespace
- vertical_whitespace_between_cases
- vertical_whitespace_closing_braces
- vertical_whitespace_opening_braces
- void_return
```
## Links
- [SwiftLint Configuration](https://github.com/realm/SwiftLint?tab=readme-ov-file#configuration)
48 changes: 48 additions & 0 deletions docs/guides/tools/tools.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: Tools
sidebar_label: Tools
description: Overview of CodeRabbit's supported linters and security analysis tools.
sidebar_position: 1
---

CodeRabbit supports various linters and security analysis tools to improve the code review process. The output of these tools is used to enhance the feedback provided by CodeRabbit, making it possible to provide 1-click fixes for common issues.

## Enabling/Disabling Tools

You can enable or disable tools by setting `reviews.tools.<linter>.enabled` in your project's `.coderabbit.yaml` file or setting the "Review → Tools → Linter → Enabled" field in CodeRabbit's settings page.

## Customizing Tools

CodeRabbit supports customizing the strictness of tools by setting `reviews.profile` in your project's `.coderabbit.yaml` file or setting the "Review → Profile" field in CodeRabbit's settings page. The following profiles are available:

- `Chill` - Yields less feedback, that may be considered lenient.
- `Assertive` - Yields more feedback, that may be considered nit-picky.

Apart from the overall profile, you can also configure each tool by providing a configuration file (specific to the tool) in your project. This would allow you to further customize the tool's behavior, by enabling/disabling specific rules, setting rule severity, etc.

## Checking Tool Output

When a tool is enabled, CodeRabbit will run it on your change request and attach the output under "Review details" comment in the change request. The output will be displayed in a structured format, with information on the file, line number, and the issue detected. For example:

```text
Ruff
fib.py
21-21: f-string without any placeholders
Remove extraneous f prefix
(F541)
```

## Supported Tools

- [ShellCheck](./shellcheck.md)
- [Ruff](./ruff.md)
- [Markdownlint](./markdownlint.md)
- [LanguageTool](./languagetool.md)
- [Biome](./biome.md)
- [Hadolint](./hadolint.md)
- [SwiftLint](./swiftlint.md)
- [PHPStan](./phpstan.md)
- [golangci-lint](./golangci-lint.md)
- [YamlLint](./yamllint.md)
46 changes: 46 additions & 0 deletions docs/guides/tools/yamllint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: Yamllint
sidebar_label: Yamllint
description: CodeRabbit's guide to Yamllint.
sidebar_position: 8
---

[Yamllint](https://yamllint.readthedocs.io/en/stable/) is a linter for YAML.

## Files

Yamllint will run on files with the following extensions:

- `.yaml`
- `.yml`

## Configuration

Yamllint supports the following config files:

- `.yamllint`
- `.yamllint.yaml`
- `.yamllint.yml`

CodeRabbit will use the following settings based on the profile selected if no config file is found:

### Chill

```yaml
extends: relaxed
rules:
line-length: disable
```
### Assertive
```yaml
extends: default
rules:
line-length: disable
document-start: disable
```
## Links
- [Yamllint Configuration](https://yamllint.readthedocs.io/en/stable/configuration.html)