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
+20-29Lines changed: 20 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ Different plugin versions supports the following:
43
43
3. Start SonarQube and enable rules
44
44
4.[TSQL] (Optional) Install [SQLCodeGuard](https://www.red-gate.com/products/sql-development/sql-code-guard/index) into your build machine where you plan to run sonar scanner
45
45
5.[TSQL, MySQL, PotsgreSQL] (Optional) - Install [SQLCheck](https://github.com/jarulraj/sqlcheck) into your build machine where you plan to run sonar scanner
46
-
6.[TSQL] (Optional) Setup SQLCover reorting. You can check tsql example at here for full setup.
46
+
6.[TSQL] (Optional) Setup SQLCover reorting. You can check tsql example at [here](https://github.com/gretard/sonar-sql-plugin/tree/master/examples/1-tsql) for full setup.
47
47
48
48
## Getting started ###
49
49
Please see examples on how to use different dialects.
@@ -98,6 +98,22 @@ sonar.language=sql
98
98
sonar.sql.dialect=vsql
99
99
```
100
100
101
+
### Custom rules example ###
102
+
This is an example for sonar settings for project which uses custom plugin rules from local directory (located at ./rules directory). You can check full example at [here](https://github.com/gretard/sonar-sql-plugin/tree/master/examples/6-pssql-with-custom-rules)
103
+
```
104
+
sonar.projectKey=pssql.custom.rules
105
+
sonar.projectName=Test PSSQL custom rules project
106
+
sonar.projectVersion=1.0
107
+
sonar.sources=src
108
+
109
+
# optional
110
+
sonar.language=sql
111
+
sonar.sql.dialect=pssqlv2
112
+
113
+
# change these
114
+
sonar.sql.rules.path=./rules
115
+
```
116
+
101
117
## Plugin configuration ##
102
118
The following options are available for configuration:
With the plugin - there are additional 2 cli tools available (they are not required for sonar execution):
143
+
With the plugin - there is additional cli tool available (they are not required for sonar execution):
128
144
129
-
-**sql-sca-cli.jar** - allows to execute sql code analysis from the command line
130
145
-**rulesHelper.jar** - command line helper tool for writing custom sql rules
131
-
132
-
### sql-sca-cli
133
-
Usage:
134
146
135
-
-```java -jar sql-sca-cli.jar --help``` - will print help
136
-
-```java -jar sql-sca-cli.jar``` - will scan current directory
137
-
-```java -jar sql-sca-cli.jar -i /home/test``` - will scan test directory
138
-
139
-
Full help info:
140
-
```usage: sql-sca-cli
141
-
-c,--custom-rules-path <arg> path to custom rules directory,
142
-
defaults to current directory
143
-
-csuffix,--custom-rules-suffix <arg> custom rules suffix, defaults to:
144
-
.customRules
145
-
-d,--dialect <arg> SQL dialect, defaults to: tsql,
146
-
possible values: [TSQL, PSSQL,
147
-
MYSQL, VSQL, PSSQLV2]
148
-
-h,--help show help
149
-
-i,--input <arg> input directory for analysis,
150
-
defaults to current directory
151
-
-p,--prefixes <arg> file prefixes for analysis,
152
-
defaults to: .sql
153
-
-warnOnly,--warnOnly flag whether tool should report
154
-
warnings only
155
-
```
156
147
157
148
### rulesHelper
158
149
Usage:
@@ -177,6 +168,7 @@ verify file "c:/tests/customRules.rules;" mysql
177
168
178
169
179
170
## Contributing ##
171
+
### Developing locally
180
172
Added container definitions for easy development with VSCode. Download the [remote containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) and let it figure out the maven targets.
1) Then you can lifecycle > package target to build the plugin. The .jar file will end up in the *sonar-sql-plugin/src/sonar-sql-plugin/target/* folder.
@@ -220,6 +212,5 @@ docker run \
220
212
1. Generate lexer and parser, example package: org.antlr.sql.dialects.vsql
221
213
2. Implement SQLDialect extending BaseDialect.class, i.e. VSQLDialect
222
214
3. Implement sql rules, example VSQLRules
223
-
4. Register rules at SQLDialectRules
215
+
4. Register rules at SQLDialectRules. This step is optional as plugin will support custom rules from user project provided in xml format.
224
216
5. Update ./src/external/README.md with references to your added grammar
0 commit comments