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
@@ -45,6 +48,8 @@ _Windows and MacOS binaries will be added in a later release._
45
48
46
49
## Usage
47
50
51
+
### Basic Usage
52
+
48
53
Analyze a Ballerina source file by passing its path to `blazelint`:
49
54
50
55
```bash
@@ -56,21 +61,88 @@ blazelint path/to/file.bal
56
61
57
62
The tool prints the input program, a token stream, the parsed AST, and exits or emits diagnostics if there is any and exits with a non-zero status.
58
63
64
+
### Development Usage
65
+
59
66
Running from a checked-out repository is also supported:
60
67
61
68
```bash
62
69
cargo run -- path/to/file.bal
63
70
```
64
71
65
72
> [!NOTE]
66
-
> `cargo run` builds and executes an unoptimized build (for debug requirments). Always use `cargo build --release` for any benchmark or observations on performance.
73
+
> `cargo run` builds and executes an unoptimized build (for debug requirements). Always use `cargo build --release` for any benchmark or observations on performance.
67
74
68
-
For a quick smoke test, you can reuse the sample program in `tests/test.bal`:
75
+
For a quick smoke test, you can reuse the sample program in `tests/test-bal-files/`:
69
76
70
77
```bash
71
-
blazelint tests/test.bal
78
+
blazelint tests/test-bal-files/simple_errors.bal
79
+
```
80
+
81
+
## Configuration
82
+
83
+
### Configuration File
84
+
85
+
Blazelint looks for a `.blazerc` configuration file in the current directory or any parent directory. The configuration uses TOML format:
86
+
87
+
```toml
88
+
# .blazerc - Blazelint Configuration File
89
+
90
+
[rules]
91
+
# Naming convention rules
92
+
camel-case = "error"# Enforces camelCase for variables/functions
93
+
constant-case = "warn"# Enforces SCREAMING_SNAKE_CASE for constants
94
+
95
+
# Code style rules
96
+
line-length = "warn"# Limits line length
97
+
max-function-length = "error"# Limits function body length
98
+
missing-return = "error"# Ensures functions have return statements
Blazelint searches for `.blazerc` files in this order:
132
+
133
+
1.**Current directory**: `./.blazerc`
134
+
2.**Parent directories**: Walks up the directory tree looking for `.blazerc`
135
+
3.**Default configuration**: Uses built-in defaults if no file found
136
+
137
+
### Rule Engine
138
+
139
+
The rule engine features:
140
+
141
+
-**Dynamic Rule Loading**: Only enabled rules are executed
142
+
-**Configurable Severity**: Each rule respects configured severity levels
143
+
-**Caching**: Configuration is cached for performance
144
+
-**Extensible Design**: New rules can be added easily
145
+
74
146
## Development environment
75
147
76
148
A pre-configured [Dev Container](https://containers.dev/) is available that can be used to investigate, develop or debug the program without installing anything on the host machine.
@@ -98,6 +170,15 @@ The container comes with:
98
170
- Ballerina runtime
99
171
- Extensions for Language Servers, syntax highlighting and debugging support
100
172
- Common utilities (zsh, GitHub CLI, git, etc.)
173
+
174
+
### Development Dependencies
175
+
176
+
The project uses the following key dependencies:
177
+
178
+
-**Core**: Standard library only for main linting logic
179
+
-**Configuration**: `serde`, `toml` for config file parsing
180
+
-**Utilities**: `once_cell`, `thiserror` for error handling and caching
181
+
-**Testing**: `assert_cmd`, `tempfile` for integration tests
101
182
102
183
## Building
103
184
@@ -133,7 +214,8 @@ The container comes with:
133
214
- Ballerina toolchain and IDE extension (optional - for testing or writing ballerina codes)
134
215
135
216
### Steps
136
-
- You can adjust the `tests/test.bal` file if you need to debug a specific diagnostic.
217
+
- You can adjust the `tests/test-bal-files/` files if you need to debug a specific diagnostic.
218
+
- Create a `.blazerc` config file to test configuration changes.
137
219
- Set breakpoints as needed.
138
220
- Click on **Run and Debug** from the main method or use `ctrl+shift+D` to jump to debug menu.
139
221
@@ -144,6 +226,7 @@ The container comes with:
144
226
145
227
- Changes should be developed and push to following branches based on the area of the feature.
146
228
- feature/linter-core: Changes to the linter engine (lexer, parser, semantic analyzer and BNF document).
229
+
- feature/rule-engine: Changes to rule engine, configuration system, and linter rules.
147
230
- ci/cd: Changes related to continous integration and deployments.
148
231
- docs: Changes related to documentation.
149
232
@@ -153,6 +236,26 @@ The container comes with:
153
236
bash scripts/check.sh
154
237
```
155
238
239
+
### Adding New Rules
240
+
241
+
When adding a new linter rule:
242
+
243
+
1. **Create the rule**: Implement the `LintRule` trait in`src/linter/rules/`
244
+
2. **Register the rule**: Add to the rule registry in`src/lib.rs`
0 commit comments