Skip to content
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

sonarlint plugin doesn't work #16589

Closed
yshcoffee opened this issue Apr 13, 2020 · 16 comments · Fixed by eclipse-che/che-plugin-registry#531
Closed

sonarlint plugin doesn't work #16589

yshcoffee opened this issue Apr 13, 2020 · 16 comments · Fixed by eclipse-che/che-plugin-registry#531
Labels
area/plugins kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system.

Comments

@yshcoffee
Copy link

sonarlint plugin doesn't work (eclipse che version: 7.7.0)

Soanrlint is not visible, but javalint is visible.

Please, tell me how to use Sonarlint plugin.

sonarlint plugin test order:

  1. create workspace: Java Maven Stack

  2. Eclipse Che UI Workspaces > configure workspace > Plugins > vscode-sonarlint Enable > Apply

  3. File > Settings > Open Preferences > input
    {
    "sonarlint.connectedMode.servers": [
    {
    "serverId": "my_sonarqube",
    "serverUrl": "http://172.22.11.2:9000",
    "token": "457be3c16b703110e68380bcc7f53b2727b2771c"
    }
    ],
    "sonarlint.ls.javaHome": "/usr/lib/jvm/java-1.8-openjdk",
    "sonarlint.connectedMode.project": {
    "serverId": "my_sonarqube",
    "projectKey": "petclinic"
    }
    }

  4. F1 > Update Sonarlint binding to SonarQube/SonarCloud

  5. Result: Solarlint seems unapplied
    image

Is there anything else I need to set up?

@yshcoffee yshcoffee added the kind/question Questions that haven't been identified as being feature requests or bugs. label Apr 13, 2020
@che-bot che-bot added the status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. label Apr 13, 2020
@vparfonov vparfonov added area/plugins and removed status/need-triage An issue that needs to be prioritized by the curator responsible for the triage. See https://github. labels Apr 13, 2020
@ericwill ericwill added kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system. and removed kind/question Questions that haven't been identified as being feature requests or bugs. labels Apr 14, 2020
@ericwill
Copy link
Contributor

Something isn't working, unless I am missing some step. It works fine in VS Code but fails on Che.

@ericwill ericwill mentioned this issue Apr 22, 2020
52 tasks
@ericwill ericwill mentioned this issue May 13, 2020
43 tasks
@ericwill ericwill added this to the Backlog - Plugins milestone Jun 3, 2020
@ericwill ericwill mentioned this issue Jun 24, 2020
31 tasks
@ericwill ericwill removed this from the Backlog - Plugins milestone Jun 24, 2020
@tsmaeder
Copy link
Contributor

Well, sonarlint simply does not support Java in the version we have in the plugin registry: these are the activation events:

"activationEvents": [
    "onLanguage:javascript",
    "onLanguage:javascriptreact",
    "onLanguage:typescript",
    "onLanguage:typescriptreact",
    "onLanguage:python",
    "onLanguage:php",
    "onLanguage:vue",
    "onLanguage:html",
    "onLanguage:jsp",
    "onLanguage:apex",
    "onLanguage:plsql",
    "onCommand:SonarLint.UpdateAllBindings",
    "onView:SonarLint.AllRules"
  ],

@tsmaeder
Copy link
Contributor

I was able to make V 1.16.0 of the extension work for Java if I include the Java extension in the Che plugin.

@tsmaeder
Copy link
Contributor

Seems if I just activate the Java Che plugin, Java support in does not work for sonarlint. Same with typescript support:

Unable to locate TypeScript extension. TypeScript support in SonarLint might not work.

@benoitf
Copy link
Contributor

benoitf commented Jul 3, 2020

I think there are couple of issues

  1. bug in extensionDependency/extensionDependencies handling (upstream theia)
  • we're not handling extensionDependency field (only extensionDependencies) (extensionDependency is deprecated)
    but then it means that extensions might search for typescript while it should be vscode.typescript (always a prefix)

so sonalint could be updated to match the correct/new way of searching extensions with the identifier or we need to add prefix vscode. on missing requests

  1. bug in remote calls of che-theia. vscode-java is not exporting objects in the same way than other extensions does (like yaml/kubernetes). Needs to be fixed in che-theia/remote stuff.
    For now we're able to find redhat.java extension but not all of its exported members.

benoitf added a commit to benoitf/che-theia that referenced this issue Jul 6, 2020
Handle more properties from the exports
also handle constants directly (as some plugin's are checking if the returned value is a string and not a function that might return a string)

Change-Id: Icbb026f65577422168f1acab486e598c6146c170
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
@benoitf
Copy link
Contributor

benoitf commented Jul 6, 2020

For java support, meta.yaml of latest sonarlint (1.16.0) version should contain as well

      volumes:
      - mountPath: "/home/theia/.m2"
        name: m2

as it tries to load m2 dependencies

benoitf added a commit to benoitf/che-theia that referenced this issue Jul 6, 2020
Handle more properties from the exports
also handle constants directly (as some plugin's are checking if the returned value is a string and not a function that might return a string)

Change-Id: Icbb026f65577422168f1acab486e598c6146c170
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
@benoitf
Copy link
Contributor

benoitf commented Jul 6, 2020

After eclipse-che/che-theia#794 is merged, there is one remaining problem for typescript

it's because sonarlint VS Code plug-in, grab the extension path named vscode.typescript-language-features

const tsExt = VSCode.extensions.getExtension('vscode.typescript-language-features');
..
const bundledTypeScriptPath = Path.resolve(tsExt.extensionPath, '..', 'node_modules', 'typescript', 'lib');

but as it's in another container, filesystem access is not OK

so either, we need to:

  • copy typescript lib into a sonarlint plug-in with exact same path (difficult as there is a random name generated by the plugin-broker)
  • having sonarlint running in the typescript sidecar (but then it's require both java and typescript)
  • embed/unpack the vsix inside the image of typescript sidecar and then avoid to download plug-in from the plug-in broker (so we can have the same path in typescript sidecar and sonarlint sidecar)
  • update sonarlint to specify an absolute path for typescript and provide sidecar with this lib

@tsmaeder
Copy link
Contributor

tsmaeder commented Jul 7, 2020

Sonarlint looking up the typescript libs is conceptually the same problem as #16851: it's trying to pick up a target environment. So we should

  1. Enable sonarlint to pick up typescript via a preference (it already does so for java)
  2. Use the same mechanism as in 16851 to provide typescript.

@tsmaeder
Copy link
Contributor

tsmaeder commented Jul 7, 2020

When I fixed the field extensionDependency to the correct extensionDependencies, the plugin activation of the sonarlint plugin now fails saying

Activating extension 'SonarLint' failed: Dependent extension 'typescript' is not installed.

Seems the name that works is vscode.typescript

@benoitf
Copy link
Contributor

benoitf commented Jul 7, 2020

in fact the real name is vscode.typescript-language-features
see SonarSource/sonarlint-vscode#97

benoitf added a commit to eclipse-che/che-theia that referenced this issue Jul 7, 2020
Handle more properties from the exports
also handle constants directly (as some plugin's are checking if the returned value is a string and not a function that might return a string)

Change-Id: Icbb026f65577422168f1acab486e598c6146c170
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
@tsmaeder
Copy link
Contributor

Sonarlint would already pickup the setting typescript.tsdk. Maybe we can weasel up something around that.

@benoitf
Copy link
Contributor

benoitf commented Jul 10, 2020

it looks like I don't see anymore one of my comment on this issue I paste few hour ago.

This is what I was instructing typescript.tsd in the devfile, to specify that value so that Sonarlint can find it.
To use local typescript install instead of typescript version bundled in the sidecar.

@benoitf
Copy link
Contributor

benoitf commented Jul 10, 2020

this preference in devfile

  - id: che-incubator/typescript/latest
    type: chePlugin
    memoryLimit: 1512Mi
    preferences:
      typescript.tsdk: "/projects/react-web-app/node_modules/typescript/lib"

then add node runtime in the sidecar of sonarlint

and then it worked
sonarlint-typescript

@tsmaeder
Copy link
Contributor

We'd have to do the same for the typescript plugin, as well, though: preferences are shared among sidecars.

@benoitf
Copy link
Contributor

benoitf commented Jul 10, 2020

@tsmaeder I'm doing that on the typescript plug-in

@benoitf
Copy link
Contributor

benoitf commented Jul 10, 2020

what would be nice is to be able to specify it in the meta.yaml and not in the devfile.yaml (maybe it's what you were saying) ?

but for that it means we should have multi-workspace root enabled to always have the relative ./node_modules/typescript/lib path

BTW it's nice to have the typescript really used by the project but extension switch to default if node_modules is not there

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/plugins kind/bug Outline of a bug - must adhere to the bug report template. severity/P1 Has a major impact to usage or development of the system.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants