question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Linter Checking file that does not exist

See original GitHub issue

Describe the bug Linter fails on attempting to lint on a file that does not exist. Happens both locally on computer and remotely on circleci

  1. On CircleCI

Unable to run the complete lint test, please check the following stack trace and fix the errors:
+--------------------------+
Traceback (most recent call last):
  File "scripts/concurrent_task_utils.py", line 61, in run
    self.output = self.func()
  File "scripts/linters/js_ts_linter.py", line 860, in perform_all_lint_checks
    self.parsed_js_and_ts_files = self._validate_and_parse_js_and_ts_files()
  File "scripts/linters/js_ts_linter.py", line 185, in _validate_and_parse_js_and_ts_files
    file_content = FILE_CACHE.read(compiled_js_filepath)
  File "/home/circleci/oppia/scripts/linters/pre_commit_linter.py", line 168, in read
    return self._get_data(filepath, mode)[0]
  File "/home/circleci/oppia/scripts/linters/pre_commit_linter.py", line 199, in _get_data
    with python_utils.open_file(filepath, mode) as f:
  File "python_utils.py", line 106, in open_file
    raise IOError('Unable to open file: %s' % filename)
IOError: Unable to open file: /home/circleci/oppia/tmpcompiledjs8IV6JQ/translation-language-select.component.js
  1. Locally (it seems to happen on a different file)
Unable to run the complete lint test, please check the following stack trace and fix the errors:
+--------------------------+
Traceback (most recent call last):
  File "scripts/concurrent_task_utils.py", line 61, in run
    self.output = self.func()
  File "scripts/linters/js_ts_linter.py", line 862, in perform_all_lint_checks
    self.parsed_js_and_ts_files = self._validate_and_parse_js_and_ts_files()
  File "scripts/linters/js_ts_linter.py", line 182, in _validate_and_parse_js_and_ts_files
    file_content = FILE_CACHE.read(compiled_js_filepath)
  File "/Users/davidchenggoogle/opensource/oppia/scripts/linters/pre_commit_linter.py", line 167, in read
    return self._get_data(filepath, mode)[0]
  File "/Users/davidchenggoogle/opensource/oppia/scripts/linters/pre_commit_linter.py", line 198, in _get_data
    with python_utils.open_file(filepath, mode) as f:
  File "python_utils.py", line 106, in open_file
    raise IOError('Unable to open file: %s' % filename)
IOError: Unable to open file: /Users/davidchenggoogle/opensource/oppia/tmpcompiledjsRjCxNX/translation-language-select.component.spec.js

To Reproduce Steps to reproduce the behavior:

  1. Go to PR #9443
  2. Run linters

Observed behavior A clear and concise description of what you have observed.

  1. Linter fails trying to access oppia/tmpcompiledjs8IV6JQ/translation-language-select.component.js

Expected behavior A clear and concise description of what you expected to happen.

  1. Linter does not check file that does not exist

Desktop (please complete the following information; delete this section if the issue does not arise on desktop):

  • OS: MacOS 10.15.5

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:28 (26 by maintainers)

github_iconTop GitHub Comments

2reactions
shavavocommented, Jun 19, 2020

Hi all,

Here are some benchmarks I ran, there are some interesting findings Note: Benchmarking on a 2.6 GHz 6-Core i7 MBP

Benchmark - Compiling all files

  • Command used: ./node_modules/typescript/bin/tsc -p tsconfig.json -outDir tmpcompiledjs Compiling all files at once took around 15 seconds for three separate trials.

Benchmark - Linter

  • Method: I isolated JsTsLintChecksManager._validate_and_parse_js_and_ts_files by:

    • in JsTsLintChecksManager.perform_all_lint_checks, commenting out everything except self._validate_and_parse_js_and_ts_files(), and returning an empty array instead of all_messages to indicate success.
    • Similarly, in ThirdPartyJsTsLintChecksManager.perform_all_lint_checks, comment out everything and return [] to skip checks
  • Command used: python -m scripts.linters.pre_commit_linter --path core/templates/services/

branch trial 1 trial 2 trial 3 average
develop 244s 239s 238s 240.3s
#9580 50s 58s 48s 52s
  • Note: On branch develop, for the core/templates/services directory alone, esprima fails and we use _compile_ts_file 144 times, causing a massive slow down compared to compiling all at once.

Discussion

It appears #9580 is significantly faster than develop when it comes to running many files at once. However, much of the use case of pre_comit_linter is to only check files that have been modified, instead of running on a big directory of files. In this case, where we only need to check a few files, we should expect a maximum increase of 15s of runtime.

@ankita240796 @vojtechjelinek @seanlip @Hudda thoughts? Is this tradeoff worth it?

Let me know if there are any other benchmarks you would like to see. Perhaps knowing how many esprima fails equate to compiling all files would be useful.

0reactions
U8NWXDcommented, Aug 1, 2022

This doesn’t happen anymore

Read more comments on GitHub >

github_iconTop Results From Across the Web

no file specified or specified file does not exist puppet-lint ...
Open the file at: ~/.atom/packages/linter-puppet-lint/lib/main.js . Change the line throw output; to throw file; ...
Read more >
Showing lint errors which does not exist - CircleCI Discuss
Hi, In Oppia, we are use lint tests to figure out all the lint errors which occur in the code. For linting, we...
Read more >
Is there a linter check to confirm that a related file has been ...
If you have a CI system set up for your repository, you can run a command like the following, which will exit nonzero...
Read more >
How to check if a file exists in Golang - Educative.io
In Golang, we can use the Stat() function in the os package to check if a file exists or not. Syntax. fileInfo, error...
Read more >
Configuration — SQLFluff 1.4.5 documentation
For details of what's available on the command line check out the CLI Reference. ... You don't need any config files to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found