Skip to content

Commit

Permalink
Remove reverse engineered analyzer
Browse files Browse the repository at this point in the history
  • Loading branch information
greeneca committed May 24, 2019
1 parent dbe21fd commit 76401d7
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 746 deletions.
27 changes: 2 additions & 25 deletions lib/roku_builder/plugins/analyzer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,43 +30,25 @@ def self.dependencies
def analyze(options:, quiet: false)
@options = options
@warnings = []
analyzer_config = get_config("inspector_config.json")
performance_config = get_config("performance_config.json")
linter_config = get_config(".roku_builder_linter.json", true)
linter_config ||= {}
@inspector_config = analyzer_config[:inspectors]
loader = Loader.new(config: @config)
Dir.mktmpdir do |dir|
loader.copy(options: options, path: dir)
raf_inspector = RafInspector.new(config: @config, dir: dir)
manifest_inspector = ManifestInspector.new(config: @config, dir: dir, raf: raf_inspector)
@warnings.concat(manifest_inspector.run(analyzer_config[:inspectors]))
has_source_dir = false
libraries = @config.project[:libraries]
libraries ||= []
Dir.glob(File.join(dir, "**", "*")).each do |file_path|
file = file_path.dup; file.slice!(dir)
unless libraries.any_is_start?(file) and not @options[:include_libraries]
if File.file?(file_path) and file_path.end_with?(".brs", ".xml")
line_inspector_config = analyzer_config[:lineInspectors]
line_inspector_config += performance_config
line_inspector_config = performance_config
line_inspector_config += linter_config[:rules] if linter_config[:rules]
line_inspector = LineInspector.new(config: @config, raf: raf_inspector, inspector_config: line_inspector_config, indent_config: linter_config[:indentation])
line_inspector = LineInspector.new(inspector_config: line_inspector_config, indent_config: linter_config[:indentation])
@warnings.concat(line_inspector.run(file_path))
end
if file_path.end_with?("__MACOSX")
add_warning(warning: :packageMacosxDirectory, path: file_path)
end
if file_path.end_with?(".zip", ".md", ".pkg")
add_warning(warning: :packageExtraneousFiles, path: file_path)
end
end
has_source_dir = true if file_path.end_with?("source")
end
unless has_source_dir
add_warning(warning: :packageSourceDirectory, path: "source")
end
@warnings.concat(raf_inspector.run(analyzer_config[:inspectors]))
format_messages(dir)
print_warnings unless quiet
end
Expand All @@ -84,11 +66,6 @@ def get_config(file, project_root=false)
JSON.parse(File.open(file).read, {symbolize_names: true}) if File.exist? file
end

def add_warning(warning:, path:)
@warnings.push(@inspector_config[warning].deep_dup)
@warnings.last[:path] = path
end

def print_warnings
logger = ::Logger.new(STDOUT)
logger.level = @logger.level
Expand Down
5 changes: 1 addition & 4 deletions lib/roku_builder/plugins/line_inspector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
module RokuBuilder

class LineInspector
def initialize(config:, raf:, inspector_config:, indent_config:)
@config = config
@raf_inspector = raf
def initialize(inspector_config:, indent_config:)
@inspector_config = inspector_config
@indent_config = indent_config
end
Expand Down Expand Up @@ -45,7 +43,6 @@ def run(file_path)
end
end
end
@raf_inspector.inspect_line(line: line, file: file_path, line_number: line_number)
end
@warnings += indent_inspector.warnings if indent_inspector
end
Expand Down
224 changes: 0 additions & 224 deletions lib/roku_builder/plugins/manifest_attributes.json

This file was deleted.

Loading

0 comments on commit 76401d7

Please sign in to comment.