add updates libs

This commit is contained in:
Christoph Brandau
2026-06-18 17:21:58 +02:00
parent 91ce762570
commit 41f331d4c4
150 changed files with 8249 additions and 2550 deletions
+41 -16
View File
@@ -1,16 +1,17 @@
import re
from tclint.commands import get_commands
from tclint.violations import Rule, Violation
from tclint.commands.plugins import PluginManager
from tclint.config import Config
from tclint.syntax_tree import (
Visitor,
BracedExpression,
Expression,
BracedWord,
QuotedWord,
CommandSub,
Expression,
QuotedWord,
Script,
Visitor,
)
from tclint.violations import Rule, Violation
class LineLengthChecker:
@@ -81,11 +82,13 @@ class RedefinedBuiltinChecker(Visitor):
Reports 'redefined-builtin' violations.
"""
def check(self, _, tree, config):
self._violations = []
def __init__(self, plugin_manager: PluginManager):
self._plugin_manager = plugin_manager
plugins = [config.commands] if config.commands is not None else []
commands = get_commands(plugins)
def check(self, _, tree: Script, config: Config) -> list[Violation]:
self._violations: list[Violation] = []
commands = self._plugin_manager.get_commands(config.commands)
self._commands = commands.keys()
tree.accept(self, recurse=True)
@@ -115,8 +118,8 @@ class RedefinedBuiltinChecker(Visitor):
class UnbracedExprChecker(Visitor):
def check(self, _, tree, __):
self._violations = []
def check(self, _, tree, __) -> list[Violation]:
self._violations: list[Violation] = []
tree.accept(self, recurse=True)
return self._violations
@@ -170,8 +173,8 @@ class UnbracedExprChecker(Visitor):
class RedundantExprChecker(Visitor):
def check(self, _, tree, __):
self._violations = []
def check(self, _, tree, __) -> list[Violation]:
self._violations: list[Violation] = []
tree.accept(self, recurse=True)
return self._violations
@@ -215,11 +218,33 @@ class RedundantExprChecker(Visitor):
self._check_operand(arg)
def get_checkers():
class UnopenedQuoteChecker(Visitor):
# Matches a literal " not preceded by backslash (escaped quotes are intentional)
BARE_QUOTE_RE = re.compile(r'(?<!\\)"')
def check(self, _, tree, __) -> list[Violation]:
self._violations: list[Violation] = []
tree.accept(self, recurse=True)
return self._violations
def visit_bare_word(self, word):
if self.BARE_QUOTE_RE.search(word.value):
self._violations.append(
Violation(
Rule.UNOPENED_QUOTE,
'found " without opening quote',
word.pos,
word.end_pos,
)
)
def get_checkers(plugin_manager: PluginManager):
checkers = (
RedefinedBuiltinChecker(),
RedefinedBuiltinChecker(plugin_manager),
UnbracedExprChecker(),
RedundantExprChecker(),
UnopenedQuoteChecker(),
LineLengthChecker(),
TrailingWhitespaceChecker(),
)