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

"No input file found for" with eslint import #1985

Closed
NatMarchand opened this issue Apr 6, 2020 · 10 comments · Fixed by #2024
Closed

"No input file found for" with eslint import #1985

NatMarchand opened this issue Apr 6, 2020 · 10 comments · Fixed by #2024
Assignees
Labels
type: bug Exceptions and blocking issues during analysis
Milestone

Comments

@NatMarchand
Copy link

I'm currently encountering a bug.
SonarJS version: 6.2.0.12043
SonarQube version: 7.9.3.33349

I have a nodejs project in the folder e:\dev\somewhere\mysources
I'm running a eslint which outputs a report to e:\dev\somewhere\mysources\report\eslint.json
which looks like this:

[{"filePath":"e:\\dev\\somewhere\\mysources\\components\\Authentication\\index.js","messages":[],"errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0}]

I have sonar-project.properties which looks like this :

sonar.projectKey=blabla
sonar.sources=public,components,layouts,services,styles,tools
sonar.sourceEncoding=UTF-8
sonar.eslint.reportPaths=report/eslint.json

Then I run the scanner with this command line :

E:\temp\sonar-scanner-4.2.0.1873-windows\bin\sonar-scanner.bat --debug -Dproject.settings
=sonar-project.properties -Dsonar.projectBaseDir=e:\dev\somewhere\mysources

I got the following warning and no files get analyzed correctly :

17:39:11.445 INFO: Importing E:\dev\somewhere\mysources\report\eslint.json
17:39:11.478 WARN: No input file found for e:\dev\somewhere\mysources\components\Authentication\index.js. No ESLint
issues will be imported on this file.

The file DO exists at this path and I expect the lint errors/warnings taken in account.

When I make the paths relatives in the report/eslint.json file (manually), it does work (of course it cannot be a solution to always change the values of the linter report).

@Bouke
Copy link

Bouke commented Apr 15, 2020

I'm running into the same issue. I wonder how this could ever have worked (when Sonar implemented importing), as the paths are seemingly always absolute?

@vilchik-elena
Copy link
Contributor

Ok, I found what's the problem, but not yet sure how to fix it.

Your report contains disk name e in lower-case. I believe making it capital (E) will fix your problem. On my side I've tried with ESLint 4.19.1, and it was generating upper case as expected. May be changing version of ESLint will fix generated report.

TBH I'm not sure on which side the bug is: ESLint generating bad path or ours not matching it when it's lower-case. I will try to follow up on it next week.

@saberduck
Copy link
Contributor

saberduck commented May 20, 2020

I investigated bit further, and there is inconsistency in SonarQube's API wrt. capitalization of the drive letter in windows which is demonstrated in the following test

@Test
  public void test_absolute_predicate() throws IOException {
    Path directory = Paths.get("C:\\test");
    Files.createDirectories(directory);
    Path file = directory.resolve("test.txt");
    SensorContextTester sensorContextTester = SensorContextTester.create(directory);
    DefaultInputFile inputFile = new TestInputFileBuilder("project", directory.toFile(), file.toFile()).build();
    DefaultFileSystem fs = sensorContextTester.fileSystem();
    fs.add(inputFile);
    String fileName = "C:\\test\\test.txt";
    FilePredicates p = fs.predicates();
    System.out.println(fs.hasFiles(p.hasAbsolutePath(fileName))); // TRUE
    System.out.println(fs.hasFiles(p.hasPath(fileName))); // TRUE
    System.out.println(fs.hasFiles(p.or(p.none(), p.hasAbsolutePath(fileName)))); // TRUE

    fileName = "c:\\test\\test.txt";
    System.out.println(fs.hasFiles(p.hasAbsolutePath(fileName))); // TRUE
    System.out.println(fs.hasFiles(p.hasPath(fileName))); // TRUE
    System.out.println(fs.hasFiles(p.or(p.none(), p.hasAbsolutePath(fileName)))); // FALSE !!!
  }

to workaround we can use FilePredicate#hasPath method instead of FilePredicate#or in

InputFile inputFile = context.fileSystem().inputFile(predicates.or(predicates.hasRelativePath(fileName), predicates.hasAbsolutePath(fileName)));

@NatMarchand thanks for reporting this problem, we will fix it in the next release

@saberduck saberduck added the type: bug Exceptions and blocking issues during analysis label May 20, 2020
@saberduck saberduck added this to the 6.3 milestone May 20, 2020
@vilchik-elena
Copy link
Contributor

@poyel
Copy link

poyel commented May 25, 2020

I'm having the same problem but on mac. The very strange thing is that some days ago working very well. I've make a new fresh installation of all the required libraries and it's not working as well.

@vilchik-elena
Copy link
Contributor

@poyel could you be more specific which "same" problem you have? Describe properly your issue please.

@poyel
Copy link

poyel commented May 26, 2020

@vilchik-elena Yes, sorry.
SonarQube server version 8.3
SonarJS: latest
SonarScanner: 3.1.0
I have created a new angular project to test custom tslint rules and the import of a generated report of tslint in sonaqube server.

The generation of the json report by tslint is fine, but when i run sonar-scanner utility, i have this error
WARN: No input file found for /Users/.../Documents/projects/angular/custom-tslint/src/app/app.component.ts. No TSLint issues will be imported on this file. WARN: No input file found for /Users/.../Documents/projects/angular/custom-tslint/src/app/app.component.ts. No TSLint issues will be imported on this file. WARN: No input file found for /Users/.../Documents/projects/angular/custom-tslint/src/app/app.module.ts. No TSLint issues will be imported on this file.
and in the sonarqube server has not any of these issue loaded in the project's issues.

@Bouke
Copy link

Bouke commented Jun 24, 2020

It looks like 6.3 isn't around the corner. Is there any way we can work around this issue?

@Bouke
Copy link

Bouke commented Jun 24, 2020

I thought I was running into the same problem, but the comments here suggest the system drive casing as the problem. This is not what I'm seeing. The case to the base path (D:\a\1\s\) is the same.

INFO: Importing D:\a\1\s\Source\PROJECT\eslint.json
WARN: No input file found for D:\a\1\s\Source\PROJECT\SOME\NESTED\FILE.ts. No ESLint issues will be imported on this file.

@vilchik-elena
Copy link
Contributor

@Bouke are you sure this file is part of analyzed project? do you see it imported in SQ UI?
If yes, please start a new thread as it is most probably different problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Exceptions and blocking issues during analysis
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants