From 262f57d9c4d37e01bed4594e20fb9ce2d8e6c5b9 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Wed, 15 Jan 2025 06:24:02 +0100 Subject: [PATCH] Revert "Add support for linting ECR files (#536)" (#540) This reverts commit 371414e8557eab9f4c5efd4f4f60f1472052f732. --- README.md | 1 - spec/ameba/source_spec.cr | 26 -------------------------- src/ameba.cr | 4 ---- src/ameba/config.cr | 7 +------ src/ameba/glob_utils.cr | 9 +-------- src/ameba/source.cr | 16 ---------------- 6 files changed, 2 insertions(+), 61 deletions(-) diff --git a/README.md b/README.md index 729ecfca0..58b74e6e0 100644 --- a/README.md +++ b/README.md @@ -174,7 +174,6 @@ In this example we define default globs and exclude `src/compiler` folder: ``` yaml Globs: - "**/*.cr" - - "**/*.ecr" - "!lib" Excluded: diff --git a/spec/ameba/source_spec.cr b/spec/ameba/source_spec.cr index 4b1cd4e3b..8c8b1a1b4 100644 --- a/spec/ameba/source_spec.cr +++ b/spec/ameba/source_spec.cr @@ -70,31 +70,5 @@ module Ameba CRYSTAL end end - - if Ameba.ecr_supported? - describe "#ast" do - it "parses an ECR file" do - source = Source.new <<-ECR, "filename.ecr" - hello <%= "world" %> - ECR - - source.ast.to_s.should eq(<<-CRYSTAL) - __str__ << "hello " - ("world").to_s(__str__) - - CRYSTAL - end - - it "raises an exception when ECR parsing fails" do - source = Source.new <<-ECR, "filename.ecr" - hello <%= "world" > - ECR - - expect_raises(Crystal::SyntaxException) do - source.ast - end - end - end - end end end diff --git a/src/ameba.cr b/src/ameba.cr index 94b9f141c..e675939ac 100644 --- a/src/ameba.cr +++ b/src/ameba.cr @@ -40,8 +40,4 @@ module Ameba def run(config = Config.load) Runner.new(config).run end - - def self.ecr_supported? : Bool - {{ compare_versions(Crystal::VERSION, "1.15.0") >= 0 }} - end end diff --git a/src/ameba/config.cr b/src/ameba/config.cr index 6b82e7aba..89a710e53 100644 --- a/src/ameba/config.cr +++ b/src/ameba/config.cr @@ -1,6 +1,5 @@ require "semantic_version" require "yaml" -require "ecr/processor" require "./glob_utils" # A configuration entry for `Ameba::Runner`. @@ -63,10 +62,6 @@ class Ameba::Config !lib ) - if Ameba.ecr_supported? - DEFAULT_GLOBS << "**/*.ecr" - end - getter rules : Array(Rule::Base) property severity = Severity::Convention @@ -172,7 +167,7 @@ class Ameba::Config # ``` # config = Ameba::Config.load # config.sources # => list of default sources - # config.globs = ["**/*.cr", "**/*.ecr"] + # config.globs = ["**/*.cr"] # config.excluded = ["spec"] # config.sources # => list of sources pointing to files found by the wildcards # ``` diff --git a/src/ameba/glob_utils.cr b/src/ameba/glob_utils.cr index ef6c6c6f9..63dd67cc7 100644 --- a/src/ameba/glob_utils.cr +++ b/src/ameba/glob_utils.cr @@ -24,14 +24,7 @@ module Ameba def expand(globs) globs .flat_map do |glob| - if File.directory?(glob) - glob += "/**/*.cr" - - if Ameba.ecr_supported? - glob += "/**/*.ecr" - end - end - + glob += "/**/*.cr" if File.directory?(glob) Dir[glob] end .uniq! diff --git a/src/ameba/source.cr b/src/ameba/source.cr index 010638feb..29d9d1990 100644 --- a/src/ameba/source.cr +++ b/src/ameba/source.cr @@ -57,22 +57,6 @@ module Ameba # source.ast # ``` getter ast : Crystal::ASTNode do - code = @code - - if Ameba.ecr_supported? && @path.ends_with?(".ecr") - begin - code = ECR.process_string(code, @path) - rescue ex : ECR::Lexer::SyntaxException - # Need to rescue to add the filename - raise Crystal::SyntaxException.new( - ex.message, - ex.line_number, - ex.column_number, - @path - ) - end - end - Crystal::Parser.new(code) .tap(&.wants_doc = true) .tap(&.filename = path)