roku_builder 4.8.2 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +4 -0
- data/Gemfile.lock +1 -1
- data/lib/roku_builder/array.rb +12 -0
- data/lib/roku_builder/plugins/analyzer.rb +30 -16
- data/lib/roku_builder/plugins/line_inspector.rb +5 -2
- data/lib/roku_builder/plugins/performance_config.json +27 -0
- data/lib/roku_builder/version.rb +1 -1
- data/test/roku_builder/plugins/test_analyzer.rb +80 -2
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 826bb48694fa32bff380d9ea9143772b019d3845
|
4
|
+
data.tar.gz: ab2c380e350b704fe788f04fcdab7c30655f176c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24f1e3f0f88aa3bd262e48a3f83b1a38962e0c050432da73c6d230447dbc807179577ba7ceddecb1cf1aa20b05a2c13d11e0bfea85b6e8311ae506bc0527b209
|
7
|
+
data.tar.gz: 2cb77fd249b35bfa5e4b0c819f317911642944e6ee1c47120a8773617224a1c9b7bf8c63e244fd1157eb8f5f047d029f8657e106c5a184ff50d26897751fe654
|
data/CHANGELOG
CHANGED
data/Gemfile.lock
CHANGED
@@ -17,6 +17,10 @@ module RokuBuilder
|
|
17
17
|
parser.on("--analyze", "Run a static analysis on a given stage") do
|
18
18
|
options[:analyze] = true
|
19
19
|
end
|
20
|
+
parser.separator "Options:"
|
21
|
+
parser.on("--inclide-libraries", "Include libraries in analyze") do
|
22
|
+
options[:include_libraries] = true
|
23
|
+
end
|
20
24
|
end
|
21
25
|
|
22
26
|
def self.dependencies
|
@@ -26,7 +30,9 @@ module RokuBuilder
|
|
26
30
|
def analyze(options:, quiet: false)
|
27
31
|
@options = options
|
28
32
|
@warnings = []
|
29
|
-
|
33
|
+
plugin_config = get_config(".roku_builder_analyze.json", true) || {}
|
34
|
+
analyzer_config = get_config("inspector_config.json")
|
35
|
+
performance_config = get_config("performance_config.json")
|
30
36
|
@inspector_config = analyzer_config[:inspectors]
|
31
37
|
loader = Loader.new(config: @config)
|
32
38
|
Dir.mktmpdir do |dir|
|
@@ -35,16 +41,23 @@ module RokuBuilder
|
|
35
41
|
manifest_inspector = ManifestInspector.new(config: @config, dir: dir, raf: raf_inspector)
|
36
42
|
@warnings.concat(manifest_inspector.run(analyzer_config[:inspectors]))
|
37
43
|
has_source_dir = false
|
44
|
+
libraries = plugin_config[:libraries]
|
45
|
+
libraries ||= []
|
38
46
|
Dir.glob(File.join(dir, "**", "*")).each do |file_path|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
47
|
+
file = file_path.dup; file.slice!(dir)
|
48
|
+
unless libraries.any_is_start?(file) and not @options[:include_libraries]
|
49
|
+
if File.file?(file_path) and file_path.end_with?(".brs", ".xml")
|
50
|
+
line_inspector_config = analyzer_config[:lineInspectors]
|
51
|
+
line_inspector_config += performance_config
|
52
|
+
line_inspector = LineInspector.new(config: @config, raf: raf_inspector, inspector_config: line_inspector_config)
|
53
|
+
@warnings.concat(line_inspector.run(file_path))
|
54
|
+
end
|
55
|
+
if file_path.end_with?("__MACOSX")
|
56
|
+
add_warning(warning: :packageMacosxDirectory, path: file_path)
|
57
|
+
end
|
58
|
+
if file_path.end_with?(".zip", ".md", ".pkg")
|
59
|
+
add_warning(warning: :packageExtraneousFiles, path: file_path)
|
60
|
+
end
|
48
61
|
end
|
49
62
|
has_source_dir = true if file_path.end_with?("source")
|
50
63
|
end
|
@@ -59,12 +72,13 @@ module RokuBuilder
|
|
59
72
|
|
60
73
|
private
|
61
74
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
75
|
+
def get_config(file, project_root=false)
|
76
|
+
if project_root
|
77
|
+
file = File.join(@config.root_dir, file)
|
78
|
+
else
|
79
|
+
file = File.join(File.dirname(__FILE__), file)
|
80
|
+
end
|
81
|
+
JSON.parse(File.open(file).read, {symbolize_names: true}) if File.exist? file
|
68
82
|
end
|
69
83
|
|
70
84
|
def add_warning(warning:, path:)
|
@@ -15,6 +15,7 @@ module RokuBuilder
|
|
15
15
|
line_number = 0
|
16
16
|
in_xml_comment = false
|
17
17
|
file.readlines.each do |line|
|
18
|
+
full_line = line.dup
|
18
19
|
line = line.partition("'").first if file_path.end_with?(".brs")
|
19
20
|
if file_path.end_with?(".xml")
|
20
21
|
if in_xml_comment
|
@@ -28,8 +29,10 @@ module RokuBuilder
|
|
28
29
|
in_xml_comment = true if line.gsub!(/<!--.*/, "")
|
29
30
|
end
|
30
31
|
@inspector_config.each do |line_inspector|
|
31
|
-
if /#{line_inspector[:regex]}
|
32
|
-
|
32
|
+
if /#{line_inspector[:regex]}/i.match(line)
|
33
|
+
unless /'.*ignore-warning/i.match(full_line)
|
34
|
+
add_warning(inspector: line_inspector, file: file_path, line: line_number)
|
35
|
+
end
|
33
36
|
end
|
34
37
|
end
|
35
38
|
@raf_inspector.inspect_line(line: line, file: file_path, line_number: line_number)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"regex": "\\sas\\s(Object|Boolean|String|Integer|LongInteger|Double|Float|Function|Dynamic)",
|
4
|
+
"severity": "warning",
|
5
|
+
"message": "Found function return type. Consider removing"
|
6
|
+
} ,
|
7
|
+
{
|
8
|
+
"regex": "DoesExist",
|
9
|
+
"severity": "warning",
|
10
|
+
"message": "Found DoesExist check. Try using invalid check on dot referance"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"regex": "\\[\"[^\"]+\"\\]",
|
14
|
+
"severity": "warning",
|
15
|
+
"message": "Found AA String referance. Try switching to dot referance"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"regex": "FOR.*TO",
|
19
|
+
"severity": "warning",
|
20
|
+
"message": "For loop found. Try switching to a For Each loop"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"regex": "\"roRegex\"",
|
24
|
+
"severity": "warning",
|
25
|
+
"message": "Regexp found. Avoid if possible"
|
26
|
+
}
|
27
|
+
]
|
data/lib/roku_builder/version.rb
CHANGED
@@ -9,7 +9,7 @@ module RokuBuilder
|
|
9
9
|
RokuBuilder.class_variable_set(:@@dev, false)
|
10
10
|
RokuBuilder.setup_plugins
|
11
11
|
register_plugins(Analyzer)
|
12
|
-
@config, @options = build_config_options_objects(AnalyzerTest, {analyze: true, working: true
|
12
|
+
@config, @options = build_config_options_objects(AnalyzerTest, {analyze: true, working: true}, false)
|
13
13
|
@root_dir = @config.root_dir
|
14
14
|
@device_config = @config.device_config
|
15
15
|
FileUtils.cp(File.join(@root_dir, "manifest_template"), File.join(@root_dir, "manifest"))
|
@@ -26,6 +26,7 @@ module RokuBuilder
|
|
26
26
|
def teardown
|
27
27
|
manifest = File.join(@root_dir, "manifest")
|
28
28
|
FileUtils.rm(manifest) if File.exist?(manifest)
|
29
|
+
remove_config
|
29
30
|
@request_stubs.each {|req| remove_request_stub(req)}
|
30
31
|
end
|
31
32
|
def test_analyzer_parse_commands
|
@@ -252,7 +253,7 @@ module RokuBuilder
|
|
252
253
|
def test_macosx_directory
|
253
254
|
config = good_config(AnalyzerTest)
|
254
255
|
config[:projects][:project1][:folders].push("Test__MACOSX")
|
255
|
-
@config, @options = build_config_options_objects(AnalyzerTest, {analyze: true, working: true
|
256
|
+
@config, @options = build_config_options_objects(AnalyzerTest, {analyze: true, working: true}, false, config)
|
256
257
|
folder = File.join(@root_dir, "Test__MACOSX")
|
257
258
|
Dir.mkdir(folder) unless File.exist?(folder)
|
258
259
|
warnings = test
|
@@ -297,6 +298,70 @@ module RokuBuilder
|
|
297
298
|
def test_logging_info
|
298
299
|
test_logger_with_file_content(text: "\"roSGScreen\"", severity: :info)
|
299
300
|
end
|
301
|
+
def test_performance_function_return_types
|
302
|
+
warnings = test_file(text: "function test() as String\n? \"test\"\nend function")
|
303
|
+
assert_equal 1, warnings.count
|
304
|
+
assert_match(/function return/, warnings[0][:message])
|
305
|
+
end
|
306
|
+
def test_performance_function_return_types_lowercase
|
307
|
+
warnings = test_file(text: "function test() as string\n? \"test\"\nend function")
|
308
|
+
assert_equal 1, warnings.count
|
309
|
+
assert_match(/function return/, warnings[0][:message])
|
310
|
+
end
|
311
|
+
def test_performance_aa_does_exist
|
312
|
+
warnings = test_file(text: "exists = aa.doesExist(\"test\")")
|
313
|
+
assert_equal 1, warnings.count
|
314
|
+
assert_match(/DoesExist check/, warnings[0][:message])
|
315
|
+
end
|
316
|
+
def test_performance_aa_string_ref
|
317
|
+
warnings = test_file(text: "aa[\"test\"] = \"test\"")
|
318
|
+
assert_equal 1, warnings.count
|
319
|
+
assert_match(/String referance/, warnings[0][:message])
|
320
|
+
end
|
321
|
+
def test_performance_for_loop
|
322
|
+
warnings = test_file(text: "FOR i=0 TO 10\n ? i\nEND FOR")
|
323
|
+
assert_equal 1, warnings.count
|
324
|
+
assert_match(/For loop found/, warnings[0][:message])
|
325
|
+
end
|
326
|
+
def test_performance_for_loop_lower_case
|
327
|
+
warnings = test_file(text: "for i=0 to 10\n ? i\nEND FOR")
|
328
|
+
assert_equal 1, warnings.count
|
329
|
+
assert_match(/For loop found/, warnings[0][:message])
|
330
|
+
end
|
331
|
+
def test_performance_for_loop_title_case
|
332
|
+
warnings = test_file(text: "For i=0 To 10\n ? i\nEND FOR")
|
333
|
+
assert_equal 1, warnings.count
|
334
|
+
assert_match(/For loop found/, warnings[0][:message])
|
335
|
+
end
|
336
|
+
def test_performance_regex
|
337
|
+
warnings = test_file(text: "\"roRegex\"")
|
338
|
+
assert_equal 1, warnings.count
|
339
|
+
assert_match(/Regexp found/, warnings[0][:message])
|
340
|
+
end
|
341
|
+
def test_library_skip
|
342
|
+
set_config({libraries: ["/source/test.brs"]})
|
343
|
+
warnings = test_file(text: "\"roRegex\"")
|
344
|
+
assert_equal 0, warnings.count
|
345
|
+
end
|
346
|
+
def test_library_skip_folder
|
347
|
+
set_config({libraries: ["/source"]})
|
348
|
+
warnings = test_file(text: "\"roRegex\"")
|
349
|
+
assert_equal 0, warnings.count
|
350
|
+
end
|
351
|
+
def test_library_include
|
352
|
+
@config, @options = build_config_options_objects(AnalyzerTest, {analyze: true, working: true, include_libraries: true}, false)
|
353
|
+
set_config({libraries: ["/source/test.brs"]})
|
354
|
+
warnings = test_file(text: "\"roRegex\"")
|
355
|
+
assert_equal 1, warnings.count
|
356
|
+
end
|
357
|
+
def test_performance_skip_warning_comment
|
358
|
+
warnings = test_file(text: "function test() as String 'ignore-warning\n? \"test\"\nend function")
|
359
|
+
assert_equal 0, warnings.count
|
360
|
+
end
|
361
|
+
def test_performance_skip_warning_comment_upper_case
|
362
|
+
warnings = test_file(text: "function test() as String 'IGNORE-WARNING\n? \"test\"\nend function")
|
363
|
+
assert_equal 0, warnings.count
|
364
|
+
end
|
300
365
|
|
301
366
|
|
302
367
|
private
|
@@ -342,6 +407,19 @@ module RokuBuilder
|
|
342
407
|
analyzer.analyze(options: @options, quiet: quiet)
|
343
408
|
end
|
344
409
|
|
410
|
+
def set_config(config_content)
|
411
|
+
config = File.join(@root_dir, ".roku_builder_analyze.json")
|
412
|
+
File.open(config, "w") do |file|
|
413
|
+
file.write(config_content.to_json)
|
414
|
+
end
|
415
|
+
end
|
416
|
+
|
417
|
+
def remove_config
|
418
|
+
config = File.join(@root_dir, ".roku_builder_analyze.json")
|
419
|
+
FileUtils.rm(config) if File.exist? config
|
420
|
+
end
|
421
|
+
|
422
|
+
|
345
423
|
def print_all(warnings)
|
346
424
|
warnings.each do |warning|
|
347
425
|
puts warning[:message]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roku_builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- greeneca
|
@@ -474,6 +474,7 @@ files:
|
|
474
474
|
- intergration/roku_builder/test_scripter.rb
|
475
475
|
- intergration/roku_builder/test_tester.rb
|
476
476
|
- lib/roku_builder.rb
|
477
|
+
- lib/roku_builder/array.rb
|
477
478
|
- lib/roku_builder/config.rb
|
478
479
|
- lib/roku_builder/config_parser.rb
|
479
480
|
- lib/roku_builder/config_validator.rb
|
@@ -496,6 +497,7 @@ files:
|
|
496
497
|
- lib/roku_builder/plugins/monitor.rb
|
497
498
|
- lib/roku_builder/plugins/navigator.rb
|
498
499
|
- lib/roku_builder/plugins/packager.rb
|
500
|
+
- lib/roku_builder/plugins/performance_config.json
|
499
501
|
- lib/roku_builder/plugins/profiler.rb
|
500
502
|
- lib/roku_builder/plugins/raf_inspector.rb
|
501
503
|
- lib/roku_builder/plugins/scripter.rb
|