jscop 0.1.4 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -1
- data/.stickler.yml +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +21 -18
- data/README.md +46 -46
- data/exe/jscop +3 -2
- data/jscop.gemspec +1 -1
- data/lib/classes/js_parser.rb +5 -0
- data/lib/jscop/spacing_checker.rb +66 -12
- data/lib/jscop/unused_var_checker.rb +46 -30
- data/lib/jscop/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fec0bd785ae7f1ebe5987dc2264496988e81bc43b3b805311712b475410aa96
|
4
|
+
data.tar.gz: 37f0a68427d71ff1b6c11f2e587e7c037e8ed1a075b2aea02a9e162960614c3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa88e49442c7e9ccc77e58ae69bf595c023943c100d0de60ce45734cec48b92e3064f06c96c2c06e30fb1ca77be0a67a3207f2aba3874a8a377bca81c7d7fefa
|
7
|
+
data.tar.gz: e45bc88c103e67e4f714713ba9fbd96ad8606be59c08d4e3f750050f85385f716c5c1d0814adf14ad7c67a51e59bb43b6755c7d85a079a677aef68fd47e4fc51
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
3
|
- "spec/spec_helper.rb"
|
4
|
+
- "lib/jscop/spacing_checker.rb"
|
4
5
|
- "README.md"
|
5
6
|
- "Guardfile"
|
6
7
|
- "Rakefile"
|
7
|
-
- "rof_work.rb"
|
8
8
|
- "vendor/**/*"
|
9
9
|
- "jscop.gemspec"
|
10
10
|
|
@@ -14,6 +14,8 @@ Lint/RaiseException:
|
|
14
14
|
Enabled: false
|
15
15
|
Lint/StructNewOverride:
|
16
16
|
Enabled: false
|
17
|
+
Lint/UselessAssignment:
|
18
|
+
Enabled: false
|
17
19
|
|
18
20
|
Layout/LineLength:
|
19
21
|
Max: 120
|
data/.stickler.yml
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,44 +1,47 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
jscop (0.1.
|
4
|
+
jscop (0.1.8)
|
5
5
|
colorize (~> 0.8)
|
6
6
|
tty-font (~> 0.5)
|
7
7
|
|
8
8
|
GEM
|
9
9
|
remote: https://rubygems.org/
|
10
10
|
specs:
|
11
|
-
ast (2.4.
|
11
|
+
ast (2.4.1)
|
12
12
|
colorize (0.8.1)
|
13
|
-
diff-lcs (1.
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
ast (~> 2.4.0)
|
13
|
+
diff-lcs (1.4.4)
|
14
|
+
parallel (1.19.2)
|
15
|
+
parser (2.7.1.4)
|
16
|
+
ast (~> 2.4.1)
|
18
17
|
rainbow (3.0.0)
|
19
|
-
rake (12.3.
|
18
|
+
rake (12.3.3)
|
19
|
+
regexp_parser (1.7.1)
|
20
20
|
rexml (3.2.4)
|
21
21
|
rspec (3.9.0)
|
22
22
|
rspec-core (~> 3.9.0)
|
23
23
|
rspec-expectations (~> 3.9.0)
|
24
24
|
rspec-mocks (~> 3.9.0)
|
25
|
-
rspec-core (3.9.
|
26
|
-
rspec-support (~> 3.9.
|
27
|
-
rspec-expectations (3.9.
|
25
|
+
rspec-core (3.9.2)
|
26
|
+
rspec-support (~> 3.9.3)
|
27
|
+
rspec-expectations (3.9.2)
|
28
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
29
|
rspec-support (~> 3.9.0)
|
30
30
|
rspec-mocks (3.9.1)
|
31
31
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
32
|
rspec-support (~> 3.9.0)
|
33
|
-
rspec-support (3.9.
|
34
|
-
rubocop (0.
|
35
|
-
jaro_winkler (~> 1.5.1)
|
33
|
+
rspec-support (3.9.3)
|
34
|
+
rubocop (0.89.1)
|
36
35
|
parallel (~> 1.10)
|
37
|
-
parser (>= 2.7.
|
36
|
+
parser (>= 2.7.1.1)
|
38
37
|
rainbow (>= 2.2.2, < 4.0)
|
38
|
+
regexp_parser (>= 1.7)
|
39
39
|
rexml
|
40
|
+
rubocop-ast (>= 0.3.0, < 1.0)
|
40
41
|
ruby-progressbar (~> 1.7)
|
41
42
|
unicode-display_width (>= 1.4.0, < 2.0)
|
43
|
+
rubocop-ast (0.3.0)
|
44
|
+
parser (>= 2.7.1.4)
|
42
45
|
ruby-progressbar (1.10.1)
|
43
46
|
tty-font (0.5.0)
|
44
47
|
unicode-display_width (1.7.0)
|
@@ -47,13 +50,13 @@ PLATFORMS
|
|
47
50
|
ruby
|
48
51
|
|
49
52
|
DEPENDENCIES
|
50
|
-
bundler (~> 1.
|
53
|
+
bundler (~> 2.1.0)
|
51
54
|
colorize (~> 0.8.1)
|
52
55
|
jscop!
|
53
|
-
rake (~> 12.3)
|
56
|
+
rake (~> 12.3.3)
|
54
57
|
rspec
|
55
58
|
rubocop
|
56
59
|
tty-font (~> 0.5.0)
|
57
60
|
|
58
61
|
BUNDLED WITH
|
59
|
-
1.
|
62
|
+
2.1.4
|
data/README.md
CHANGED
@@ -1,9 +1,25 @@
|
|
1
|
-
[![Gem Version](https://badge.fury.io/rb/jscop.svg)](https://badge.fury.io/rb/jscop)
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/jscop.svg)](https://badge.fury.io/rb/jscop) [![Build Status](https://travis-ci.org/codecell/jscop.svg?branch=development)](https://travis-ci.org/codecell/jscop)
|
2
2
|
|
3
3
|
# Jscop
|
4
4
|
|
5
5
|
This is a Linter for checking errors in Javascript code, built with Ruby.
|
6
6
|
|
7
|
+
## Outline
|
8
|
+
- [Installation](#Installation)
|
9
|
+
- [Usage](#Usage)
|
10
|
+
- [Errors currently detectable by jscop](#ERRORS)
|
11
|
+
- Variable naming errors
|
12
|
+
- Class naming errors
|
13
|
+
- Extra or redundant spacing errors
|
14
|
+
- Multiple declaration of classes in a file (class count) errors
|
15
|
+
- Unused variables are detected
|
16
|
+
- [More about usage](#More-About-Usage)
|
17
|
+
- [Testing this repo](#Testing-This-Repo)
|
18
|
+
- [Built With](#Built-With)
|
19
|
+
- [Contributing](#contributing)
|
20
|
+
- [Code of conduct](#Code-of-Conduct)
|
21
|
+
- [Licence](#License)
|
22
|
+
|
7
23
|
## Installation
|
8
24
|
|
9
25
|
Add this line to your application's Gemfile:
|
@@ -24,76 +40,60 @@ Or install it yourself as:
|
|
24
40
|
- once in desired path in the terminal/console, RUN
|
25
41
|
|
26
42
|
```ruby
|
27
|
-
a. jscop # To lint all *.js files in the current Path.
|
43
|
+
a. jscop # To lint all *.js files in the current $Path.
|
28
44
|
b. jscop ./**/path_to_file.js # To lint JUST a specific file.
|
29
45
|
c. jscop foldername # To lint all *.js files in a specific folder.
|
30
46
|
```
|
31
47
|
|
32
|
-
##
|
33
|
-
|
34
|
-
- Errors currently detectable by jscop
|
35
|
-
- variable naming errors
|
36
|
-
- class naming errors
|
37
|
-
- Extra or redundant spacing errors
|
38
|
-
- Multiple declaration of classes in a file (class count) errors
|
39
|
-
- Unused variables are detected
|
40
|
-
- Arguments supported to initiate linting
|
41
|
-
- Testing Javascript files with Js-Companion
|
42
|
-
- cloning Locally to local machine
|
43
|
-
- Unit Tests
|
44
|
-
- Tools used
|
45
|
-
- Code of conduct
|
46
|
-
- Contributing
|
47
|
-
|
48
|
-
## ERRORS that can currently be detected include
|
48
|
+
## ERRORS
|
49
|
+
The following erros are currently detectable by Jscop:
|
49
50
|
|
50
51
|
### VARIABLE NAMING ERRORS
|
51
|
-
- if capital letters or numbers
|
52
|
+
- if capital letters or numbers are used to start a variable name, e.g
|
52
53
|
- `*Bad practice* let 8owngoal = 4 or const Capvar = 9`
|
53
|
-
- `*Good
|
54
|
+
- `*Good practice* let owngoal = 4 or const capVar = 9`
|
54
55
|
|
55
56
|
### CLASS NAME ERRORS
|
56
|
-
- if class names begin
|
57
|
-
- if class names
|
57
|
+
- if class names begin with small letters and/or
|
58
|
+
- if class names are snake-cased or both e.g
|
58
59
|
- `*Bad practice* class badclass {} or class Bad-class {}`
|
59
|
-
- `*Good
|
60
|
+
- `*Good practice* class GoodClass {} or class Good_Class {}`
|
60
61
|
- Or if underscores and hyphen are mixed
|
61
62
|
`*Bad practice* class Bad_class-Name {}`
|
62
63
|
|
63
64
|
### SPACING ERRORS
|
64
|
-
- if
|
65
|
+
- if spaces are found at beginning of lines
|
65
66
|
- if extra spaces are found around variables e.g
|
66
|
-
- `*Bad practice* let| |
|
67
|
-
- `*Good
|
67
|
+
- `*Bad practice* let| | vacuum = 4 or var hollow| | = 9`
|
68
|
+
- `*Good practice* let vacuum = 4 or const hollow = 9`
|
68
69
|
|
69
70
|
### CLASS COUNT ERROR
|
70
|
-
- if more than one class is defined in a
|
71
|
+
- if more than one class is defined in a module,
|
71
72
|
|
72
73
|
### UNUSED VARIABLE ERROR
|
73
74
|
- if a variable (var, let, const) is defined and never used.
|
74
|
-
- A lot of edge cases
|
75
|
+
- A lot of edge cases are covered here.
|
75
76
|
|
76
|
-
##
|
77
|
+
## More About Usage
|
78
|
+
Arguments Supported By jscop to Check Javascript Code
|
77
79
|
- You can pass in file(s) or a folder in any of the following cases in your terminal
|
78
|
-
- `
|
79
|
-
- `You can pass in a
|
80
|
-
- `Everything Js can be linted all at once (both files and
|
81
|
-
|
82
|
-
## Testing
|
83
|
-
- Once in the Path you intend to keep this project in the terminal of your machine
|
84
|
-
- Clone with this command git clone [repo](https://github.com/codecell/jscop.git)
|
85
|
-
-
|
86
|
-
- Install project dependencies with the command bundle install
|
87
|
-
- You can make the exe/jscop executable with the command chmod a+x exe/jscop if permission is not granted
|
88
|
-
|
89
|
-
|
90
|
-
- Ensure you have `rspec` installed, or ensure the `gem 'rspec` is listed among the gems in the `Gemfile` => then run `bundle install`
|
91
|
-
- in your console, run `rspec` or `rake` to run all the unit tests written for this project
|
80
|
+
- `You can pass in a specific file $Path to test just the file`
|
81
|
+
- `You can pass in a folder and all javascript files in it will be checked and finally`
|
82
|
+
- `Everything Js can be linted all at once (both files and folders)`
|
83
|
+
|
84
|
+
## Testing this Repo
|
85
|
+
- Once in the $Path you intend to keep this project in the terminal of your machine
|
86
|
+
- Clone with this command `git clone [repo](https://github.com/codecell/jscop.git)`
|
87
|
+
- Change directory into the folder `cd jscop`
|
88
|
+
- Install project dependencies with the command `bundle install`
|
89
|
+
- You can make the `exe/jscop` file executable with the command `chmod a+x exe/jscop` if permission is not granted
|
90
|
+
- Ensure you have `rspec` installed, or ensure that `gem rspec` is listed among the gems in the `Gemfile` => then run `bundle install`
|
91
|
+
- In the console, run `rspec` or `rake` to run all the unit tests written for this project
|
92
92
|
|
93
93
|
## Built With
|
94
94
|
- Ruby
|
95
|
-
- [Rubular](https://rubular.com/)
|
96
|
-
- Rubocop
|
95
|
+
- [Rubular](https://rubular.com/) was used to craft and test the regular expressions
|
96
|
+
- Rubocop linter
|
97
97
|
- Stickler CI
|
98
98
|
|
99
99
|
## Contributing
|
data/exe/jscop
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'jscop/version'
|
3
|
-
require_relative '../lib/helpers/lint_ware'
|
4
2
|
require 'tty-font'
|
5
3
|
require 'colorize'
|
6
4
|
|
5
|
+
require 'jscop/version'
|
6
|
+
require_relative '../lib/helpers/lint_ware'
|
7
|
+
|
7
8
|
def show_title
|
8
9
|
font = TTY::Font.new
|
9
10
|
font_messge = font.write('Jscop', letter_spacing: 1)
|
data/jscop.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_runtime_dependency 'colorize', '~> 0.8'
|
24
24
|
spec.add_runtime_dependency 'tty-font', '~> 0.5'
|
25
25
|
|
26
|
-
spec.add_development_dependency 'bundler', '~> 1.
|
26
|
+
spec.add_development_dependency 'bundler', '~> 2.1.0'
|
27
27
|
spec.add_development_dependency 'rake', '~> 12.3'
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
29
29
|
end
|
data/lib/classes/js_parser.rb
CHANGED
@@ -11,10 +11,15 @@ class JsParser
|
|
11
11
|
|
12
12
|
def set_lines
|
13
13
|
file = File.open(@filename)
|
14
|
+
config_dirs = File.dirname(@filename).match?(/(node_modules|config|babel|channels|vendor)/)
|
15
|
+
|
16
|
+
files_for_escape = file if config_dirs == true
|
17
|
+
files_for_escape.to_a && config_dirs
|
14
18
|
|
15
19
|
all_lines = file.readlines.map(&:chomp)
|
16
20
|
init_lines = lambda { |val, index|
|
17
21
|
line = Line.new(index + 1, val, @filename)
|
22
|
+
|
18
23
|
@lines << line
|
19
24
|
}
|
20
25
|
|
@@ -15,27 +15,81 @@ module SpacingChecker
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.found_spaces(cont)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
/(?<lhs>\w+[\W]*)\s{2,}(?<rhs>\w+[\W]*)/ =~ cont
|
19
|
+
vsf = !Regexp.last_match.nil?
|
20
|
+
|
21
|
+
/(?<lhs>\w+\W*)\s{2,}=\s*(?<rhs>\w+\W*)/ =~ cont
|
22
|
+
beq = !Regexp.last_match.nil?
|
23
|
+
|
24
|
+
/(?<lhs>\w+\W*)\s*=\s{2,}(?<rhs>\w+\W*)/ =~ cont
|
25
|
+
aeq = !Regexp.last_match.nil?
|
26
|
+
|
27
|
+
spaced_console = /(console.log)[\s+][\(][\w\W]+[\)]/
|
28
|
+
spc = spaced_console.match?(cont)
|
29
|
+
commented_line = cont.match?(%r{^\W+[\/\/]})
|
30
|
+
|
31
|
+
!commented_line && (vsf || beq || aeq || spc)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.spc_around_fn(cont)
|
35
|
+
around_funcs = /[\)][\s]{2,}[\{]/.match?(cont)
|
36
|
+
around_classes = /[\w+\-*]*[\s]{2,}[\{]/.match?(cont)
|
22
37
|
|
23
38
|
commented_line = cont.match?(%r{^\W+[\/\/]})
|
24
39
|
|
25
|
-
|
26
|
-
|
27
|
-
|
40
|
+
!commented_line && (around_funcs || around_classes)
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.closing_curly_spacing(cont)
|
44
|
+
spaced_closing_curly = /[\s]+[\}][\s]*/
|
45
|
+
c = spaced_closing_curly.match(cont)
|
46
|
+
|
47
|
+
commented_line = cont.match?(%r{^\W+[\/\/]})
|
28
48
|
|
29
|
-
|
49
|
+
c && !commented_line
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.closed_curly(cont)
|
53
|
+
cont.match?(/}/)
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.open_curly(cont)
|
57
|
+
cont.match?(/{/)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.line_beginining_spaces(line)
|
61
|
+
/^[\s+][\w\W]*/.match?(line)
|
30
62
|
end
|
31
63
|
|
32
64
|
def self.check_spaces(file)
|
65
|
+
seen_open = false
|
66
|
+
counter = 0
|
33
67
|
lines_with_spaces = []
|
34
|
-
|
35
|
-
|
36
|
-
|
68
|
+
|
69
|
+
opening_tracker = 0
|
70
|
+
closing_tracker = 0
|
71
|
+
|
72
|
+
arr = file.lines
|
37
73
|
err_type = 'SPACING_ERR'
|
38
|
-
|
74
|
+
|
75
|
+
while counter < arr.length
|
76
|
+
line = arr[counter]
|
77
|
+
|
78
|
+
seen_open = true if open_curly(line.content)
|
79
|
+
|
80
|
+
opening_tracker += 1 if line.content.match?(/{/)
|
81
|
+
closing_tracker += 1 if line.content.match?(/}/) && !line.content.match?(/[\}][\s]*[\)]/)
|
82
|
+
|
83
|
+
lines_with_spaces << line.number if line_beginining_spaces(line.content) unless seen_open
|
84
|
+
opt = (opening_tracker == closing_tracker)
|
85
|
+
seen_open = false if closed_curly(line.content) && opt
|
86
|
+
|
87
|
+
lines_with_spaces << line.number if closing_curly_spacing(line.content) && opt
|
88
|
+
lines_with_spaces << line.number if found_spaces(line.content) && !lines_with_spaces.nil?
|
89
|
+
lines_with_spaces << line.number if spc_around_fn(line.content)
|
90
|
+
|
91
|
+
counter += 1
|
92
|
+
end
|
39
93
|
|
40
94
|
lines_with_spaces.each { |line| raise_err(line, err_type, file.filename) if !lines_with_spaces.empty? }
|
41
95
|
end
|
@@ -14,29 +14,53 @@ module UnusedVarChecker
|
|
14
14
|
unused_var_err
|
15
15
|
end
|
16
16
|
|
17
|
-
def self.
|
18
|
-
|
19
|
-
|
17
|
+
def self.check_escapable(elem)
|
18
|
+
escapables = [
|
19
|
+
'', 'var', 'let', 'const', 'constructor', 'class', 'super', 'function', 'static', 'console',
|
20
|
+
'prototype', 'get', 'set', 'this', 'alert', 'prompt', 'return', 'export', 'import', 'default',
|
21
|
+
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
22
|
+
]
|
23
|
+
|
24
|
+
escapables.include?(elem)
|
25
|
+
end
|
20
26
|
|
21
|
-
|
27
|
+
def self.vars_parentesis(paramz)
|
28
|
+
/(?<lhs>[\(])(?<rhs>[^\{]*[\w\-]+)/ =~ paramz
|
29
|
+
vars = Regexp.last_match(:rhs)
|
30
|
+
vars = vars.to_s.split if vars
|
31
|
+
vars_match_data = vars.to_s.split
|
22
32
|
|
23
|
-
|
33
|
+
each_var = vars_match_data.collect { |var|
|
24
34
|
/([\w\-]+)/ =~ var
|
25
|
-
wanted = Regexp.last_match
|
35
|
+
wanted = Regexp.last_match(0)
|
26
36
|
wanted = wanted.to_s
|
27
|
-
|
28
|
-
all_params << wanted.to_s if !wanted.empty?
|
37
|
+
wanted
|
29
38
|
}
|
39
|
+
each_var[0] if each_var[0] && !each_var.nil?
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.match_accessd_var(vari)
|
43
|
+
/(?<lhs>[\w+\-*]+)[\[](?<rhs>[\w+\-*]+)/ =~ vari
|
44
|
+
sqad = Regexp.last_match(:rhs)
|
45
|
+
|
46
|
+
/(?<lhs>[\w+\-*]+)\.(?<rhs>[\w+\-*]+)/ =~ vari
|
47
|
+
awda = Regexp.last_match(:rhs)
|
48
|
+
|
49
|
+
sqad || awda
|
30
50
|
end
|
31
|
-
# /(?<lhs>\w+)\s*=\s*(?<rhs>\w+)/ =~ " x = y " <= From: https://ruby-doc.org/core-2.6.4/Regexp.html
|
32
51
|
|
33
|
-
# rubocop:disable Lint/UselessAssignment
|
34
52
|
def self.match_variable(contents)
|
35
53
|
/(?<lhs>\w+)\s*=\s*(?<rhs>\w*\W*)/ =~ contents
|
54
|
+
equals_var = Regexp.last_match(:lhs)
|
55
|
+
|
56
|
+
/(?<lhs>(let|var|const))\s{1,}(?<rhs>[\w\-]*)/ =~ contents
|
57
|
+
lazy_init_var = Regexp.last_match(:rhs)
|
36
58
|
|
37
|
-
lhs
|
59
|
+
/(?<lhs>\w+)\s*(?<rhs>[\(\w+\)]*)/ =~ contents
|
60
|
+
func_call_var = Regexp.last_match(:lhs)
|
61
|
+
|
62
|
+
lazy_init_var || func_call_var || equals_var
|
38
63
|
end
|
39
|
-
# rubocop:enable Lint/UselessAssignment
|
40
64
|
|
41
65
|
def self.create_variables_check_info(count_vs_var, lines_vs_var, filename)
|
42
66
|
err_type = 'UNUSED_VAR_ERR'
|
@@ -59,31 +83,23 @@ module UnusedVarChecker
|
|
59
83
|
lines_variables_hash = {}
|
60
84
|
|
61
85
|
line_check = lambda { |line|
|
62
|
-
|
63
|
-
vars_match_data = Regexp.last_match
|
64
|
-
|
65
|
-
vars_match_data = vars_match_data if !vars_match_data.nil?
|
66
|
-
vars_match_data_str_arr = vars_match_data.to_s.split
|
86
|
+
commented_line = line.content.to_s.match?(%r{^\W+[\/\/]})
|
67
87
|
|
68
|
-
|
88
|
+
from_parentsis = vars_parentesis(line.content.to_s) if !commented_line
|
89
|
+
lines_variables_hash[line.number] = from_parentsis if from_parentsis
|
90
|
+
variable_instances << from_parentsis if !check_escapable(from_parentsis) && !from_parentsis.nil?
|
69
91
|
|
70
|
-
|
71
|
-
|
72
|
-
wanted = Regexp.last_match
|
73
|
-
wanted = wanted.to_s
|
74
|
-
lines_variables_hash[line.number] = wanted if wanted
|
75
|
-
variable_instances << wanted if !escapables.include?(wanted)
|
76
|
-
}
|
92
|
+
detected_var = match_variable(line.content.to_s) if !commented_line
|
93
|
+
detected_accessd_var = match_accessd_var(line.content.to_s) if !commented_line
|
77
94
|
|
78
|
-
|
95
|
+
lines_variables_hash[line.number] = detected_var if detected_var
|
96
|
+
lines_variables_hash[line.number] = detected_accessd_var if detected_accessd_var
|
79
97
|
|
80
|
-
|
81
|
-
|
82
|
-
variable_instances << detected_variable if detected_variable
|
98
|
+
variable_instances << detected_var if !check_escapable(detected_var) && !detected_var.nil?
|
99
|
+
variable_instances << detected_accessd_var if !check_escapable(detected_accessd_var) && !detected_accessd_var.nil?
|
83
100
|
}
|
84
101
|
|
85
102
|
file.lines.each(&line_check)
|
86
|
-
|
87
103
|
variable_instances.map { |el|
|
88
104
|
var_instances_count_hash[el] = var_instances_count_hash[el] ? var_instances_count_hash[el] += 1 : 1
|
89
105
|
}
|
data/lib/jscop/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jscop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezaka Alfred
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 2.1.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 2.1.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
requirements: []
|
139
|
-
rubygems_version: 3.
|
139
|
+
rubygems_version: 3.1.4
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: A linter for checking errors in javascript code
|