|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | | -require "cc/engine/analyzers/analyzer_base" |
| 3 | +require "cc/engine/analyzers/javascript/main" |
4 | 4 |
|
5 | 5 | module CC |
6 | 6 | module Engine |
7 | 7 | module Analyzers |
8 | | - module TypeScript |
9 | | - class Main < CC::Engine::Analyzers::Base |
| 8 | + module TypeScript # TODO: inconsistent naming w/ Javascript |
| 9 | + class Main < CC::Engine::Analyzers::Javascript::Main |
10 | 10 | PATTERNS = [ |
11 | 11 | "**/*.ts", |
12 | 12 | "**/*.tsx", |
13 | 13 | ].freeze |
14 | | - LANGUAGE = "typescript" |
15 | | - DEFAULT_MASS_THRESHOLD = 45 |
16 | | - DEFAULT_FILTERS = [ |
17 | | - "(ImportDeclaration ___)".freeze, |
18 | | - "(VariableDeclarator _ (init (CallExpression (_ (Identifier require)) ___)))".freeze, |
19 | | - ].freeze |
20 | | - DEFAULT_POST_FILTERS = [ |
21 | | - "(NUKE ___)".freeze, |
22 | | - "(Program _ ___)".freeze, |
23 | | - ].freeze |
24 | | - POINTS_PER_OVERAGE = 30_000 |
25 | | - REQUEST_PATH = "/typescript".freeze |
26 | | - |
27 | | - def use_sexp_lines? |
28 | | - false |
29 | | - end |
30 | | - |
31 | | - ## |
32 | | - # Transform sexp as such: |
33 | | - # |
34 | | - # s(:Program, :module, s(:body, ... )) |
35 | | - # => s(:NUKE, s(:Program, :module, s(:NUKE, ... ))) |
36 | | - |
37 | | - def transform_sexp(sexp) |
38 | | - return sexp unless sexp.body |
39 | 14 |
|
40 | | - sexp.body.sexp_type = :NUKE # negate top level body |
41 | | - sexp = s(:NUKE, sexp) # wrap with extra node to force full process |
42 | | - |
43 | | - sexp |
44 | | - end |
45 | | - |
46 | | - private |
47 | | - |
48 | | - def process_file(file) |
49 | | - parse(file, REQUEST_PATH) |
50 | | - end |
51 | | - |
52 | | - def default_filters |
53 | | - DEFAULT_FILTERS.map { |filter| Sexp::Matcher.parse filter } |
54 | | - end |
| 15 | + LANGUAGE = "typescript" |
55 | 16 |
|
56 | | - def default_post_filters |
57 | | - DEFAULT_POST_FILTERS.map { |filter| Sexp::Matcher.parse filter } |
58 | | - end |
| 17 | + REQUEST_PATH = "/typescript".freeze |
59 | 18 | end |
60 | 19 | end |
61 | 20 | end |
|
0 commit comments