-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathmain.rb
48 lines (41 loc) · 1.14 KB
/
main.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# frozen_string_literal: true
require "cc/engine/analyzers/analyzer_base"
require "cc/engine/analyzers/javascript/parser"
require "cc/engine/analyzers/javascript/minification_checker"
require "cc/engine/analyzers/javascript/node"
require "cc/engine/analyzers/file_list"
require "flay"
require "json"
module CC
module Engine
module Analyzers
module Javascript
class Main < CC::Engine::Analyzers::Base
PATTERNS = [
"**/*.js",
"**/*.jsx",
].freeze
LANGUAGE = "javascript"
DEFAULT_MASS_THRESHOLD = 40
POINTS_PER_OVERAGE = 30_000
def transform_sexp(sexp)
sexp.flatter
end
private
def process_file(path)
ast = js_parser.new(File.read(path), path).parse
Node.new(ast.syntax_tree, path).format if ast
end
def js_parser
::CC::Engine::Analyzers::Javascript::Parser
end
def skip?(path)
if MinificationChecker.new(path).minified?
"the file is minified"
end
end
end
end
end
end
end