mathiasrw / closure-linter

Automatically exported from code.google.com/p/closure-linter
Apache License 2.0
0 stars 0 forks source link

GJSLint returns an error when a file begins with semicolon #67

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a file beginning with a semicolon like this one:

;(function() {
    console.log('Hello Google!');
}());

2. Execute gjslint on it.

What is the expected output? What do you see instead?
Expected: Results of the GJSLint
Obtained: An error

Traceback (most recent call last):
  File "/usr/local/bin/gjslint", line 9, in <module>
    load_entry_point('closure-linter==2.3.10', 'console_scripts', 'gjslint')()
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/gjslint.py", line 254, in main
    _PrintErrorRecords(records_iter_copy)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/gjslint.py", line 204, in _PrintErrorRecords
    for record in error_records:
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/gjslint.py", line 126, in _CheckPaths
    results = _CheckPath(path)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/gjslint.py", line 142, in _CheckPath
    runner.Run(path, error_handler)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/runner.py", line 141, in Run
    stop_token=error_token)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/runner.py", line 193, in _RunChecker
    stop_token=stop_token)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/checker.py", line 90, in Check
    self._ExecutePass(start_token, self._LintPass, stop_token)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/checkerbase.py", line 183, in _ExecutePass
    pass_function(token)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/checkerbase.py", line 154, in _LintPass
    self._lint_rules.CheckToken(token, self._state_tracker)
  File "/Library/Python/2.7/site-packages/closure_linter-2.3.10-py2.7.egg/closure_linter/javascriptlintrules.py", line 505, in CheckToken
    if (previous_token.type == Type.KEYWORD and
AttributeError: 'NoneType' object has no attribute 'type'

What version of the product are you using? On what operating system?
- Version tested: Closure linter 2.3.10
- OS: MacOS X 10.8.3

Please provide any additional information below.

Solution:

Change javascriptlintrules.py line 505 with this:

      if (previous_token != None and previous_token.type == Type.KEYWORD and

In order to check if previous_token exists.

Original issue reported on code.google.com by adgllore...@gmail.com on 16 May 2013 at 8:46

GoogleCodeExporter commented 9 years ago
I'll handle this one.

Original comment by vagra...@google.com on 29 Jul 2013 at 6:19

GoogleCodeExporter commented 9 years ago
Any progress on this?

Original comment by xzy...@gmail.com on 29 Oct 2013 at 3:06

GoogleCodeExporter commented 9 years ago
Fixed in v2.3.12.

Original comment by vagra...@google.com on 29 Oct 2013 at 3:23

GoogleCodeExporter commented 9 years ago
Thanks, I was on 2.3.11

Original comment by xzy...@gmail.com on 29 Oct 2013 at 3:36