Skip to content

Commit aae5a62

Browse files
authored
Merge pull request #20 from bcdev/forman-reduce_code_duplications
Reduce code duplications
2 parents 7803dc0 + 57e0976 commit aae5a62

30 files changed

+833
-409
lines changed

CHANGES.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
## Version 0.3.0 (in development)
44

5+
- Fixed problem where referring to values in modules via
6+
the form `"<module>:<attr>"` raised. #21
7+
8+
- Introduced factory method `new_plugin` which simplifies
9+
creating plugin objects.
10+
11+
- Refactored out new common mixin class `Operation`
12+
which reduces amount of code and simplifies testing
13+
of operation classes `Rule`, `Processor`, `Formatter`.
14+
15+
- Improved overall test coverage.
16+
517

618
## Version 0.2.0 (14.01.2025)
719

docs/api.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ This chapter provides a plain reference for the XRLint Python API.
1010
dataset:
1111
[new_linter()][xrlint.linter.new_linter] factory function and the
1212
[Linter][xrlint.linter.Linter] class.
13-
- The `plugin` module provides plugin related classes:
14-
[Plugin][xrlint.plugin.Plugin] and its
15-
metadata [PluginMeta][xrlint.plugin.PluginMeta].
13+
- The `plugin` module provides plugin related components:
14+
A factory [new_plugin][xrlint.plugin.new_plugin] to create instances of
15+
the [Plugin][xrlint.plugin.Plugin] class that comprises
16+
plugin metadata represented by [PluginMeta][xrlint.plugin.PluginMeta].
1617
- The `config` module provides classes that represent
1718
configuration information and provide related functionality:
1819
[Config][xrlint.config.Config] and [ConfigList][xrlint.config.ConfigList].
@@ -51,6 +52,12 @@ Note:
5152

5253
::: xrlint.linter.Linter
5354

55+
::: xrlint.plugin.new_plugin
56+
57+
::: xrlint.plugin.Plugin
58+
59+
::: xrlint.plugin.PluginMeta
60+
5461
::: xrlint.config.Config
5562

5663
::: xrlint.config.ConfigList
@@ -79,10 +86,6 @@ Note:
7986

8087
::: xrlint.node.AttrNode
8188

82-
::: xrlint.plugin.Plugin
83-
84-
::: xrlint.plugin.PluginMeta
85-
8689
::: xrlint.processor.define_processor
8790

8891
::: xrlint.processor.Processor

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: xrlint-310
1+
name: xrlint
22
channels:
33
- conda-forge
44
dependencies:

examples/plugin_config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55

66
from xrlint.config import Config
77
from xrlint.node import DatasetNode
8-
from xrlint.plugin import Plugin
9-
from xrlint.plugin import PluginMeta
8+
from xrlint.plugin import new_plugin
109
from xrlint.rule import RuleContext
1110
from xrlint.rule import RuleOp
1211

1312

14-
plugin = Plugin(
15-
meta=PluginMeta(name="hello-plugin", version="1.0.0"),
13+
plugin = new_plugin(
14+
name="hello-plugin",
15+
version="1.0.0",
1616
configs={
1717
# "configs" entries must be `Config` objects!
1818
"recommended": Config.from_value(

tests/formatters/helpers.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from xrlint.config import Config
22
from xrlint.formatter import FormatterContext
3-
from xrlint.plugin import Plugin
4-
from xrlint.plugin import PluginMeta
3+
from xrlint.plugin import new_plugin
54
from xrlint.result import Message, ResultStats
65
from xrlint.result import Result
76
from xrlint.rule import RuleOp
@@ -28,7 +27,7 @@ def get_context(max_warnings: int = -1) -> FormatterContext:
2827

2928
def get_test_results():
3029

31-
plugin = Plugin(meta=PluginMeta(name="test"))
30+
plugin = new_plugin(name="test")
3231

3332
@plugin.define_rule(
3433
"rule-1", description="Haha", docs_url="https://rules.com/haha.html"

tests/formatters/test_markdown.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/test_formatters.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ def test_import_formatters(self):
1010
{
1111
"html",
1212
"json",
13-
"markdown",
1413
"simple",
1514
},
1615
set(registry.keys()),

tests/test_linter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
from xrlint.constants import CORE_PLUGIN_NAME
88
from xrlint.linter import Linter
99
from xrlint.linter import new_linter
10-
from xrlint.plugin import Plugin
11-
from xrlint.plugin import PluginMeta
10+
from xrlint.plugin import new_plugin
1211
from xrlint.node import (
1312
AttrsNode,
1413
AttrNode,
@@ -62,7 +61,7 @@ class LinterVerifyTest(TestCase):
6261

6362
def setUp(self):
6463

65-
plugin = Plugin(meta=PluginMeta(name="test"))
64+
plugin = new_plugin(name="test")
6665

6766
@plugin.define_rule("no-space-in-attr-name")
6867
class AttrVer(RuleOp):

0 commit comments

Comments
 (0)