You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+94-66Lines changed: 94 additions & 66 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,32 +6,31 @@
6
6
7
7
[中文](./README_zh.md)
8
8
9
-
Reviewbot assists you in rapidly establishing a self-hosted code analysis and review service, supporting multiple languages and coding standards. It is particularly suitable for organizations with numerous private repositories.
9
+
Reviewbot assists you in rapidly establishing a self-hosted code analysis and review service, supporting multiple languages and coding standards. Its main features include:
10
10
11
-
All issues are reported during the Pull Request stage, either as `Review Comments` or `Github Annotations`, precisely pinpointing the relevant code lines.
11
+
-**Universal Compatibility** - Provides a universal way to integrate and execute Linters without coding
12
+
-**Multi-Platform Support** - Currently supports both GitHub and GitLab
13
+
-**AI-Powered** - Detected issues are analyzed by AI to provide detailed explanations and improvement suggestions
14
+
-**Precise Feedback** - All issues are reported during the Pull/Merge Request stage as comments, precisely pinpointing the relevant code lines
15
+
-**Self-Hosted Deployment** - Recommended self-hosting for better data security and control
Reviewbot is a self-hosted code analysis and review service supporting multiple languages and coding standards. It is particularly beneficial for organizations with numerous private repositories:
54
+
Reviewbot is a self-hosted code analysis and review service with the following features:
56
55
56
+
-**Universal Compatibility** - Provides a universal way to integrate new code checking tools without modifying source code
57
+
-**Multi-Platform Support** - Currently supports both GitHub and GitLab platforms
58
+
-**AI-Powered** - Issues detected are analyzed by AI to provide detailed context and fix suggestions
57
59
-**Security** - Recommended self-hosting for data security and control
58
-
-**Improvement-Oriented** - Detected issues are primarily reported in the form of Review Comments or Github Annotations, facilitating efficient problem resolution and code improvement
59
-
-**Flexibility** - Supports multiple languages and coding standards, with easy integration of new code inspection tools
60
+
-**Improvement-Oriented** - Detected issues are primarily reported as comments precise to code lines, facilitating efficient problem resolution
61
+
-**Flexibility** - Supports multiple languages and coding standards with flexible configuration
60
62
-**Observability** - Supports alert notifications for timely awareness of detected issues
61
-
-**Configurable** - Supports configuration of linter execution commands, parameters, and environments, providing flexibility for complex scenarios
62
-
63
-
Reviewbot is developed using Golang, featuring simple logic and clear code, making it easy to understand and maintain.
64
63
65
64
## Installation
66
65
@@ -71,14 +70,65 @@ The following are internal usage practices at Qiniu, which may provide you with
71
70
- Deployed in a [Kubernetes cluster](https://github.com/qiniu/reviewbot/tree/master/deploy/reviewbot.yaml)
72
71
- Using this [Dockerfile](https://github.com/qiniu/reviewbot/tree/master/Dockerfile) to build the Reviewbot image
73
72
73
+
## Linter Integration Guide
74
+
75
+
### Universal Linter Integration (No Coding Required)
76
+
77
+
Reviewbot provides a universal way to integrate new code checking tools without modifying the source code.
For more complex scenarios, you can also consider code integration:
114
+
115
+
- For self-implemented linters or standards, refer to [commit msg check](/internal/linters/git-flow/commit/), [go mod check](/internal/linters/go/gomodcheck/), etc.
116
+
- For customizing linter execution logic in complex scenarios, refer to [golangci-lint](/internal/linters/go/golangci_lint/), [gofmt](/internal/linters/go/gofmt/), etc.
117
+
74
118
## Supported Linters
75
119
120
+
The following are the linters currently supported by Reviewbot:
@@ -106,9 +156,7 @@ The following are internal usage practices at Qiniu, which may provide you with
106
156
107
157
## Configuration
108
158
109
-
Reviewbot adheres to a **zero-configuration principle** whenever possible, with fixed code logic for general repository inspections. However, some special requirements can be met through configuration.
110
-
111
-
Note: All configurable items are defined in the `config/config.go` file. Please refer to this file for detailed configuration options.
159
+
Reviewbot adheres to a **zero-configuration principle** whenever possible, but also provides flexible configuration capabilities for special requirements. All configurable items are defined in the `config/config.go` file.
112
160
113
161
The following are some common configuration scenarios:
114
162
@@ -164,6 +212,14 @@ qbox/net-gslb:
164
212
165
213
This configuration means that the `golangci-lint` check is disabled for the `qbox/net-gslb` repository.
166
214
215
+
We can also globally disable a linter, like this:
216
+
217
+
```yaml
218
+
customLinters:
219
+
golangci-lint:
220
+
enable: false
221
+
```
222
+
167
223
### Cloning multiple repositories
168
224
169
225
By default, Reviewbot clones the repository where the event occurs. However, in some scenarios, we might want to clone multiple repositories, and customizing the cloning path.
@@ -216,52 +272,20 @@ qiniu/reviewbot:
216
272
namespace: "reviewbot"
217
273
```
218
274
275
+
## AI Enhancement
276
+
277
+
Reviewbot integrates AI analysis capabilities to provide more detailed explanations and improvement suggestions for detected issues:
278
+
279
+

280
+
219
281
## Reviewbot Operational Flow
220
282
221
-
Reviewbot primarily operates as a GitHub Webhook service, accepting GitHub Events, executing various checks, and providing precise feedback on the corresponding code if issues are detected.
283
+
Reviewbot primarily operates as a Webhook service, accepting GitHub or GitLab Events, executing various checks, and providing precise feedback on the corresponding code if issues are detected.
222
284
223
285
```
224
-
Github Event -> Reviewbot -> Execute Linter -> Provide Feedback
286
+
Webhook Event -> Reviewbot -> Execute Linter -> Provide Feedback
225
287
```
226
288
227
-
### Basic Flow:
228
-
229
-
- Event received, determine if it's a Pull Request
230
-
- Retrieve code:
231
-
- Get the code affected by the PR
232
-
- Clone the main repository
233
-
- The main repository serves as a cache
234
-
- Checkout the PR and place it in a temporary directory
235
-
- Pull submodules
236
-
- If the repository uses submodule management, code is automatically pulled
237
-
- Enter Linter execution logic
238
-
- Filter linters
239
-
- By default, all supported linters apply to all repositories unless individually configured
240
-
- Individual configurations need to be explicitly specified in the configuration file
- Execute the corresponding command and obtain the output results
245
-
- Filter the output results, only obtaining the parts relevant to this PR
246
-
- Some linters focus on code
247
-
- Some linters focus on other aspects
248
-
- Provide feedback
249
-
- Some linters provide Code Comments, precise to the code line
250
-
- Some linters provide issue comments
251
-
252
-
## How to Add a New Linter?
253
-
254
-
- Please select an Issue you want to address from the [issues](https://github.com/qiniu/reviewbot/issues) list.
255
-
- Of course, if there isn't one, you can first create an Issue describing the Linter you want to add
256
-
- Coding
257
-
- Based on the language or domain the linter focuses on, [choose the appropriate code location](https://github.com/qiniu/reviewbot/tree/master/internal/linters)
258
-
- The implementation logic for most linters is divided into three main parts:
259
-
- Execute the linter, generally by calling the relevant executable program
260
-
- Process the linter's output, focusing only on the output related to the current PR
261
-
- Provide feedback on the output related to the current PR, precise to the code line
262
-
- Deployment: If your linter is an external executable program, you'll need to add instructions on how to install this linter in the [Dockerfile](https://github.com/qiniu/reviewbot/blob/master/Dockerfile)
263
-
- Documentation: To facilitate subsequent use and maintenance, we should [add appropriate documentation here](https://github.com/qiniu/reviewbot/tree/master/docs/website/docs/components)
264
-
265
289
## Monitoring Detection Results
266
290
267
291
Reviewbot supports notification of detection results through WeWork (企业微信) alerts. For specific implementation details, refer to [here](https://github.com/qiniu/reviewbot/blob/8bfb122a2e4292f1cc74aedab8f51d1a0c149d55/internal/metric/metrics.go#L17).
@@ -280,6 +304,10 @@ If unexpected output is encountered, notifications will also be sent, like this:
280
304
281
305
For unexpected outputs, **it usually means that the default execution configuration of the relevant linter does not support the current repository**. In such cases, you need to explicitly specify the configuration through a configuration file based on the actual situation.
282
306
307
+
## Give it a Star! ⭐
308
+
309
+
If you like this project or are using it to learn or start your own solution, please give it a star to receive updates about new versions. Your support matters!
310
+
283
311
## Contributing
284
312
285
313
Your contributions to Reviewbot are essential for its long-term maintenance and improvement. Thanks for supporting Reviewbot!
0 commit comments