-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e865063
commit 69fc6c9
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Ameba::Rule::Lint | ||
# A rule that reports when there's no semantic information available for a given type. | ||
# This usually happens when there's a file in the codebase not covered by an entrypoint. | ||
# | ||
# YAML configuration example: | ||
# | ||
# ``` | ||
# Lint/NoSemanticInformation: | ||
# Enabled: true | ||
# ``` | ||
class NoSemanticInformation < Base | ||
properties do | ||
since_version "1.7.0" | ||
description "Reports types that don't have any semantic information available" | ||
severity :warning | ||
end | ||
|
||
MSG = "This type doesn't have any semantic information (double check the ameba entrypoints)" | ||
|
||
def test(source, context : SemanticContext?) | ||
return if context.nil? | ||
|
||
AST::SemanticVisitor.new self, source, context | ||
end | ||
|
||
def test( | ||
source, | ||
node : Crystal::ClassDef | Crystal::ModuleDef | | ||
Crystal::LibDef | Crystal::EnumDef, | ||
current_type : Crystal::Type, | ||
) | ||
return if current_type.lookup_type?(node.name) | ||
|
||
issue_for node.name, MSG | ||
end | ||
end | ||
end |