coc-sonarlint 0.0.0-development
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ignore +1 -0
- package/LICENSE +21 -0
- package/README.md +122 -0
- package/analyzers/sonargo.jar +0 -0
- package/analyzers/sonarhtml.jar +0 -0
- package/analyzers/sonariac.jar +0 -0
- package/analyzers/sonarjava.jar +0 -0
- package/analyzers/sonarjs.jar +0 -0
- package/analyzers/sonarphp.jar +0 -0
- package/analyzers/sonarpython.jar +0 -0
- package/analyzers/sonartext.jar +0 -0
- package/analyzers/sonarxml.jar +0 -0
- package/esbuild.mjs +24 -0
- package/lib/index.js +5607 -0
- package/package.json +459 -0
- package/server/sonarlint-ls.jar +0 -0
package/.ignore
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lib
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 Svetlozar Iliev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# SonarLint for Coc.nvim
|
|
2
|
+
|
|
3
|
+
SonarLint by [Sonar](https://www.sonarsource.com/) is a free IDE extension that empowers you to fix coding issues before they exist. More than a linter, SonarLint detects and highlights issues that can lead to bugs, vulnerabilities, and code smells as you create your code. It offers clear remediation guidance and educational help, so you can fix issues before the code is committed.
|
|
4
|
+
Out of the box, SonarLint in Coc supports analysis of JS/TS, Python, PHP, Java, C, C++, C#, Go, and IaC code locally in your IDE.
|
|
5
|
+
|
|
6
|
+
Sonar's [Clean Code solutions](https://www.sonarsource.com/solutions/clean-code/) help developers deliver high-quality, efficient code standards that benefit the entire team or organization.
|
|
7
|
+
|
|
8
|
+
## How it works
|
|
9
|
+
|
|
10
|
+
Simply open any source file, start coding, and you will start seeing issues reported by SonarLint. Issues are highlighted in your code You can access the detailed rule description directly from your editor, using the provided contextual menu.
|
|
11
|
+
|
|
12
|
+
## Static Analysis Rules
|
|
13
|
+
|
|
14
|
+
Out of the box, SonarLint automatically checks your code against the following rules:
|
|
15
|
+
|
|
16
|
+
- [Azure Resource Manager rules](https://rules.sonarsource.com/azureresourcemanager)
|
|
17
|
+
- [C rules](https://rules.sonarsource.com/c)
|
|
18
|
+
- [C++ rules](https://rules.sonarsource.com/cpp)
|
|
19
|
+
- [C# rules](https://rules.sonarsource.com/csharp/)
|
|
20
|
+
- [CloudFormation rules](https://rules.sonarsource.com/cloudformation)
|
|
21
|
+
- [CSS rules](https://rules.sonarsource.com/css)
|
|
22
|
+
- [Docker rules](https://rules.sonarsource.com/docker)
|
|
23
|
+
- [Go rules](https://rules.sonarsource.com/go)
|
|
24
|
+
- [HTML rules](https://rules.sonarsource.com/html)
|
|
25
|
+
- [Java rules](https://rules.sonarsource.com/java)
|
|
26
|
+
- [JavaScript rules](https://rules.sonarsource.com/javascript)
|
|
27
|
+
- [Kubernetes rules](https://rules.sonarsource.com/kubernetes)
|
|
28
|
+
- [Python and IPython notebook rules](https://rules.sonarsource.com/python)
|
|
29
|
+
- [PHP rules](https://rules.sonarsource.com/php)
|
|
30
|
+
- [Secrets rules](https://rules.sonarsource.com/secrets)
|
|
31
|
+
- [Terraform rules](https://rules.sonarsource.com/terraform)
|
|
32
|
+
- [TypeScript rules](https://rules.sonarsource.com/typescript)
|
|
33
|
+
|
|
34
|
+
## Requirements
|
|
35
|
+
|
|
36
|
+
The SonarLint language server needs a Java Runtime (JRE) 17+. If you do not have one provided in your path, please install it first. Below you will find the details on how to setup your environment
|
|
37
|
+
|
|
38
|
+
1. the `sonarlint.ls.javaHome` variable in Coc settings if set. For instance:
|
|
39
|
+
|
|
40
|
+
```json
|
|
41
|
+
{
|
|
42
|
+
"sonarlint.ls.javaHome": "C:\\Program Files\\Java\\jdk-17"
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
2. embedded JRE for platform-specific installations
|
|
47
|
+
3. the value of the `JDK_HOME` environment variable if set
|
|
48
|
+
4. the value of the `JAVA_HOME` environment variable if set
|
|
49
|
+
5. on Windows the registry is queried
|
|
50
|
+
6. if a JRE is still not found then:
|
|
51
|
+
1. the `PATH` is scanned for `javac`
|
|
52
|
+
2. on macOS, the parent directory of `javac` is checked for a `java_home` binary. If that binary exists then it is executed and the result is used
|
|
53
|
+
3. the grandparent directory of `javac` is used. This is similar to `$(dirname $(dirname $(readlink $(which javac))))`
|
|
54
|
+
|
|
55
|
+
SonarLint then uses the first JRE found in these steps to check its version. If a suitable JRE cannot be found at those places, SonarLint will ask for your permission to download and manage its own version.
|
|
56
|
+
|
|
57
|
+
This extension also provides a custom root directory where the sonar lint binaries are to be found, in case you do not desire to use the one bundled with this extension
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"sonarlint.ls.directly": "/home/yourname/sonarlint"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The directory must contain two folders, a server/ and analyzers/, where the server binary is located in the server/ folder and all analyzer binaries are located in the analyzers/ folder
|
|
66
|
+
|
|
67
|
+
### JS/TS analysis specific requirements
|
|
68
|
+
|
|
69
|
+
To analyze JavaScript and TypeScript code, SonarLint requires a Node.js executable. The minimal supported version is `18.18` for standalone analysis or Connected Mode with SonarCloud. For Connected Mode with SonarQube, it depends on the version of the JS/TS analyzer on your SonarQube server. SonarLint will attempt to automatically locate Node, or you can force the location using:
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"sonarlint.pathToNodeExecutable": "/home/yourname/.nvm/versions/node/v18.18.0/bin/node"
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Analysis of TypeScript in Connected Mode with SonarQube requires the server to use version 8.1 or above.
|
|
78
|
+
|
|
79
|
+
### C and C++ analysis specific requirements
|
|
80
|
+
|
|
81
|
+
To analyze C and C++ code, SonarLint requires compile commands json file
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"sonarlint.pathToCompileCommands": "/home/yourname/repos/proj/compile_commands.json"
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Note: if you are using Microsoft compiler, the environment should be ready to build the code.
|
|
90
|
+
|
|
91
|
+
### Java analysis specific requirements
|
|
92
|
+
|
|
93
|
+
To enable the support for Java analysis, you need the coc-java extension
|
|
94
|
+
|
|
95
|
+
### Jupyter notebooks
|
|
96
|
+
|
|
97
|
+
SonarLint for Coc supports analysis of Python code inside Jupyter notebooks.
|
|
98
|
+
|
|
99
|
+
## Other settings
|
|
100
|
+
|
|
101
|
+
It is possible to specify extra analyzer properties that will be used for analysis. Example:
|
|
102
|
+
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"sonarlint.analyzerProperties": {
|
|
106
|
+
"sonar.javascript.node.maxspace": "4096",
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Contributions
|
|
112
|
+
|
|
113
|
+
Have a need in SonarLint that’s not being met? Or not being met well? Ever wish you could talk directly to the Product Manager? Well now’s your chance! Congratulations, you are SonarLint’s Product Manager for a day. If you would like to see a new feature, please create a new thread in the Community Forum here, under ["Product Manager for a Day"](https://community.sonarsource.com/c/sl/pm-for-a-day-sl/41).
|
|
114
|
+
|
|
115
|
+
With that in mind, if you would like to submit a code contribution, please create a pull request for this repository. Please explain your motives to contribute: what problem you are trying to fix, what improvement you are trying to make.
|
|
116
|
+
|
|
117
|
+
## License
|
|
118
|
+
|
|
119
|
+
Copyright 2017-2024 SonarSource.
|
|
120
|
+
|
|
121
|
+
Licensed under the [GNU Lesser General Public License, Version 3.0](http://www.gnu.org/licenses/lgpl.txt)
|
|
122
|
+
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/esbuild.mjs
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as esbuild from 'esbuild';
|
|
2
|
+
|
|
3
|
+
const options = {
|
|
4
|
+
entryPoints: ['src/index.ts'],
|
|
5
|
+
bundle: true,
|
|
6
|
+
minify: process.env.NODE_ENV === 'production',
|
|
7
|
+
sourcemap: process.env.NODE_ENV === 'development',
|
|
8
|
+
mainFields: ['module', 'main'],
|
|
9
|
+
external: ['coc.nvim'],
|
|
10
|
+
platform: 'node',
|
|
11
|
+
target: 'node18',
|
|
12
|
+
outfile: 'lib/index.js',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
if (process.argv.length > 2 && process.argv[2] === '--watch') {
|
|
16
|
+
const ctx = await esbuild.context(options);
|
|
17
|
+
await ctx.watch();
|
|
18
|
+
console.log('watching...');
|
|
19
|
+
} else {
|
|
20
|
+
const result = await esbuild.build(options);
|
|
21
|
+
if (result.errors.length) {
|
|
22
|
+
console.error(result.errors);
|
|
23
|
+
}
|
|
24
|
+
}
|