-
Notifications
You must be signed in to change notification settings - Fork 14
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
Showing
11 changed files
with
158 additions
and
18 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
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
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 |
---|---|---|
@@ -1 +1,18 @@ | ||
"""Code diagnostic logic.""" | ||
|
||
from __future__ import annotations | ||
|
||
from pygerber.gerber.linter.event_ast_visitor import EventAstVisitor | ||
from pygerber.gerber.linter.linter import Linter | ||
from pygerber.gerber.linter.rule_violation import RuleViolation | ||
from pygerber.gerber.linter.rules import DEP001, RULE_REGISTRY, Rule, StaticRule | ||
|
||
__all__ = [ | ||
"DEP001", | ||
"RULE_REGISTRY", | ||
"EventAstVisitor", | ||
"Linter", | ||
"Rule", | ||
"RuleViolation", | ||
"StaticRule", | ||
] |
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 |
---|---|---|
|
@@ -13,3 +13,5 @@ class RuleViolation(BaseModel): | |
description: str | ||
start_offset: int | ||
end_offset: int | ||
line: int | ||
column: int |
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
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,20 @@ | ||
"""`DEP002` module contains linter rule DEP002 implementation.""" # noqa: N999 | ||
|
||
from __future__ import annotations | ||
|
||
from pygerber.gerber.ast.nodes import G55 | ||
from pygerber.gerber.linter.rules.rule import register_rule | ||
from pygerber.gerber.linter.rules.static_rule import StaticRule | ||
|
||
|
||
@register_rule | ||
class DEP002(StaticRule): | ||
"""Rule DEP002 class implements a specific linting rule.""" | ||
|
||
rule_id = "DEP002" | ||
title = "Use of deprecated G55 code." | ||
description = ( | ||
"This historic code optionally precedes D03 code. It has no effect. " | ||
"Deprecated in 2012." | ||
) | ||
trigger_nodes = (G55,) |
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 |
---|---|---|
@@ -1 +1,10 @@ | ||
"""`rules` package contains all the linting rules for Gerber files.""" | ||
|
||
from __future__ import annotations | ||
|
||
from pygerber.gerber.linter.rules.DEP001 import DEP001 | ||
from pygerber.gerber.linter.rules.DEP002 import DEP002 | ||
from pygerber.gerber.linter.rules.rule import RULE_REGISTRY, Rule | ||
from pygerber.gerber.linter.rules.static_rule import StaticRule | ||
|
||
__all__ = ["DEP001", "DEP002", "RULE_REGISTRY", "Rule", "StaticRule"] |
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
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
Empty file.
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,27 @@ | ||
from __future__ import annotations | ||
|
||
from pygerber.gerber.ast.nodes import G54, G55, File | ||
from pygerber.gerber.linter.linter import Linter | ||
from pygerber.gerber.linter.rules import DEP001, DEP002 | ||
|
||
|
||
def test_DEP001() -> None: | ||
rule = DEP001() | ||
linter = Linter([rule]) | ||
|
||
ast = File(nodes=[G54()]) | ||
|
||
violations = linter.lint(ast) | ||
|
||
assert len(list(violations)) == 1 | ||
|
||
|
||
def test_DEP002() -> None: | ||
rule = DEP002() | ||
linter = Linter([rule]) | ||
|
||
ast = File(nodes=[G55()]) | ||
|
||
violations = linter.lint(ast) | ||
|
||
assert len(list(violations)) == 1 |