From 1c1f48b3d908a58ae78f789e1abc256975427663 Mon Sep 17 00:00:00 2001 From: Charles Greene Date: Mon, 6 Jan 2020 11:20:52 -0400 Subject: [PATCH] Ignore indentation in multiline xml comments --- CHANGELOG | 16 ++++++++++++---- .../plugins/indentation_inspector.rb | 6 +++--- lib/roku_builder/plugins/line_inspector.rb | 2 +- lib/roku_builder/version.rb | 2 +- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2554182..8cc84fc 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,10 +1,18 @@ - = 4.20.2 = + = 4.21.3 = - -Fix bundler load paths for later versions of ruby + - Ignore indentation in multi-line xml comments - = 4.20.1 = + = 4.21.2 = - -Add indent-ignore and indent-reset comment processing to analyzer + - Fix bundler load paths for later versions of ruby + + = 4.21.1 = + + - Add indent-ignore and indent-reset comment processing to analyzer + + = 4.21.0 = + + - Add post stage/unstage hooks = 4.20.0 = diff --git a/lib/roku_builder/plugins/indentation_inspector.rb b/lib/roku_builder/plugins/indentation_inspector.rb index 65f308a..115fffc 100644 --- a/lib/roku_builder/plugins/indentation_inspector.rb +++ b/lib/roku_builder/plugins/indentation_inspector.rb @@ -13,11 +13,11 @@ def initialize(rules:, path:) @ind = 0 end - def check_line(line:, number:) - #byebug if number == 43 and @path.ends_with?("keyEvents.brs") + def check_line(line:, number:, comment:) + #byebug if number == 10 and @path.ends_with?(".brs") set_indentation(line: line) regexp = /^#{@character}{#{@ind}}[^#{@character}]/ - unless line =~ regexp or line == "\n" or line =~ /\'indent-ignore/ + unless line =~ regexp or line == "\n" or line =~ /\'indent-ignore/ or comment add_warning(line: number) end @prev_line = line diff --git a/lib/roku_builder/plugins/line_inspector.rb b/lib/roku_builder/plugins/line_inspector.rb index ebaa4e6..8265c34 100644 --- a/lib/roku_builder/plugins/line_inspector.rb +++ b/lib/roku_builder/plugins/line_inspector.rb @@ -14,7 +14,6 @@ def run(file_path) in_xml_comment = false indent_inspector = IndentationInspector.new(rules: @indent_config, path: file_path) if @indent_config file.readlines.each_with_index do |line, line_number| - indent_inspector.check_line(line: line, number: line_number) if indent_inspector full_line = line.dup line = line.partition("'").first if file_path.end_with?(".brs") if file_path.end_with?(".xml") @@ -28,6 +27,7 @@ def run(file_path) line.gsub!(//, "") in_xml_comment = true if line.gsub!(/