From 0ded86570c10d24ad4fff7e4fcd4b562bcd397fd Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 21 May 2019 17:28:28 -0700 Subject: [PATCH 1/2] Fix uninitialized constant with HamlLint::LinterRegistry The migration pod for the GitLab Helm Chart was failing because of the NameError: uninitialized constant HamlLint::Linter::NoPlainNodes::LinterRegistry We now explicitly specify ::HamlLint::LinterRegistry to avoid resolution errors. Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/62125 --- lib/haml_lint/inline_javascript.rb | 2 +- lib/haml_lint/linter/no_plain_nodes.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/haml_lint/inline_javascript.rb b/lib/haml_lint/inline_javascript.rb index 1b17162f71d..da6af92e82b 100644 --- a/lib/haml_lint/inline_javascript.rb +++ b/lib/haml_lint/inline_javascript.rb @@ -7,7 +7,7 @@ unless Rails.env.production? module HamlLint class Linter::InlineJavaScript < Linter - include LinterRegistry + include ::HamlLint::LinterRegistry def visit_filter(node) return unless node.filter_type == 'javascript' diff --git a/lib/haml_lint/linter/no_plain_nodes.rb b/lib/haml_lint/linter/no_plain_nodes.rb index d5cea0d07cf..c39f61fa80d 100644 --- a/lib/haml_lint/linter/no_plain_nodes.rb +++ b/lib/haml_lint/linter/no_plain_nodes.rb @@ -5,7 +5,7 @@ require 'active_support/core_ext/array/grouping' module HamlLint class Linter class NoPlainNodes < Linter - include LinterRegistry + include ::HamlLint::LinterRegistry def visit_tag(node) if inline_plain_node?(node) -- GitLab From 27381e22a92453b23f1ed75406970b37d926f1ec Mon Sep 17 00:00:00 2001 From: Stan Hu Date: Tue, 21 May 2019 19:49:14 -0700 Subject: [PATCH 2/2] Move files from lib/haml_lint to haml_lint Files in lib will be eager loaded and hence will require haml_lint to be loaded. Since this is only a development dependency, we can't assume this gem will be available in production, so it should never be loaded in production. --- .haml-lint.yml | 2 +- {lib/haml_lint => haml_lint}/inline_javascript.rb | 0 {lib/haml_lint => haml_lint}/linter/no_plain_nodes.rb | 0 lib/tasks/haml-lint.rake | 2 +- spec/{lib => }/haml_lint/linter/no_plain_nodes_spec.rb | 1 + 5 files changed, 3 insertions(+), 2 deletions(-) rename {lib/haml_lint => haml_lint}/inline_javascript.rb (100%) rename {lib/haml_lint => haml_lint}/linter/no_plain_nodes.rb (100%) rename spec/{lib => }/haml_lint/linter/no_plain_nodes_spec.rb (95%) diff --git a/.haml-lint.yml b/.haml-lint.yml index 9f3676fa080..0412b24a48c 100644 --- a/.haml-lint.yml +++ b/.haml-lint.yml @@ -7,7 +7,7 @@ exclude: - 'vendor/**/*' - 'spec/**/*' require: - - './lib/haml_lint/linter/no_plain_nodes.rb' + - './haml_lint/linter/no_plain_nodes.rb' linters: AltText: diff --git a/lib/haml_lint/inline_javascript.rb b/haml_lint/inline_javascript.rb similarity index 100% rename from lib/haml_lint/inline_javascript.rb rename to haml_lint/inline_javascript.rb diff --git a/lib/haml_lint/linter/no_plain_nodes.rb b/haml_lint/linter/no_plain_nodes.rb similarity index 100% rename from lib/haml_lint/linter/no_plain_nodes.rb rename to haml_lint/linter/no_plain_nodes.rb diff --git a/lib/tasks/haml-lint.rake b/lib/tasks/haml-lint.rake index 786efd14b1a..305e15d69d5 100644 --- a/lib/tasks/haml-lint.rake +++ b/lib/tasks/haml-lint.rake @@ -1,6 +1,6 @@ unless Rails.env.production? require 'haml_lint/rake_task' - require 'haml_lint/inline_javascript' + require Rails.root.join('haml_lint/inline_javascript') # Workaround for warnings from parser/current # Keep it even if it no longer emits any warnings, diff --git a/spec/lib/haml_lint/linter/no_plain_nodes_spec.rb b/spec/haml_lint/linter/no_plain_nodes_spec.rb similarity index 95% rename from spec/lib/haml_lint/linter/no_plain_nodes_spec.rb rename to spec/haml_lint/linter/no_plain_nodes_spec.rb index 99cc9b9bc8d..08deb5a4e9e 100644 --- a/spec/lib/haml_lint/linter/no_plain_nodes_spec.rb +++ b/spec/haml_lint/linter/no_plain_nodes_spec.rb @@ -3,6 +3,7 @@ require 'spec_helper' require 'haml_lint' require 'haml_lint/spec' +require Rails.root.join('haml_lint/linter/no_plain_nodes') describe HamlLint::Linter::NoPlainNodes do include_context 'linter' -- GitLab