From 547fec5a94d4467ae8f6011bc10344cde51c4ec5 Mon Sep 17 00:00:00 2001 From: Sijawusz Pur Rahnama Date: Tue, 14 Nov 2023 03:37:03 +0100 Subject: [PATCH] Refactor `TypeNames` to report the name itself only --- spec/ameba/rule/naming/type_names_spec.cr | 6 +++--- src/ameba/rule/naming/type_names.cr | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/ameba/rule/naming/type_names_spec.cr b/spec/ameba/rule/naming/type_names_spec.cr index aa96f649..555b21c8 100644 --- a/spec/ameba/rule/naming/type_names_spec.cr +++ b/spec/ameba/rule/naming/type_names_spec.cr @@ -7,8 +7,8 @@ module Ameba it "reports type name #{expected}", file, line do rule = Rule::Naming::TypeNames.new expect_issue rule, <<-CRYSTAL, type: type, name: name, file: file, line: line - %{type} %{name}; end - # ^{type}^{name}^^^^ error: Type name should be camelcased: #{expected}, but it was %{name} + %{type} %{name}; end + _{type} # ^{name} error: Type name should be camelcased: #{expected}, but it was %{name} CRYSTAL end end @@ -46,7 +46,7 @@ module Ameba it "reports alias name" do expect_issue subject, <<-CRYSTAL alias Numeric_value = Int32 - # ^{} error: Type name should be camelcased: NumericValue, but it was Numeric_value + # ^^^^^^^^^^^^^ error: Type name should be camelcased: NumericValue, but it was Numeric_value CRYSTAL end end diff --git a/src/ameba/rule/naming/type_names.cr b/src/ameba/rule/naming/type_names.cr index 59ce05a7..bace97a7 100644 --- a/src/ameba/rule/naming/type_names.cr +++ b/src/ameba/rule/naming/type_names.cr @@ -63,7 +63,7 @@ module Ameba::Rule::Naming expected = name.camelcase return if name == expected - issue_for node, MSG % {expected, name} + issue_for node.name, MSG % {expected, name} end end end