Skip to content

Commit fabde4e

Browse files
committed
fix: resolve CI failure and SonarQube issues
1 parent da0629b commit fabde4e

4 files changed

Lines changed: 10 additions & 15 deletions

File tree

src/treemapper/cli.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,7 @@ def _validate_budget(budget: int | None) -> None:
4242

4343

4444
def _validate_alpha(alpha: float) -> None:
45-
if alpha <= 0:
46-
_exit_error(f"--alpha must be between 0 and 1 (exclusive), got {alpha}")
47-
if alpha >= 1:
45+
if not (0 < alpha < 1):
4846
_exit_error(f"--alpha must be between 0 and 1 (exclusive), got {alpha}")
4947

5048

src/treemapper/diffctx/edges/semantic/javascript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
_TS_EXTS = {".ts", ".tsx", ".mts", ".cts"}
1414

1515
_EXPORT_DECL_RE = re.compile(
16-
r"export\s+(?:(?:const|let|var|function\*?|class|async\s+function|interface|type|enum|abstract\s+class)\s+)(\w+)",
16+
r"export\s+(?:const|let|var|function\*?|class|async\s+function|interface|type|enum|abstract\s+class)\s+(\w+)",
1717
re.MULTILINE,
1818
)
1919
_EXPORT_DEFAULT_NAME_RE = re.compile(

src/treemapper/diffctx/parsers/text.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55

66
from ..types import Fragment, FragmentId, extract_identifiers
7-
from .base import GENERIC_MAX_LINES, MIN_FRAGMENT_WORDS, check_library_available, create_snippet, find_sentence_boundary
7+
from .base import GENERIC_MAX_LINES, check_library_available, create_snippet, find_sentence_boundary
88

99
logger = logging.getLogger(__name__)
1010

@@ -97,9 +97,6 @@ def _flush_paragraph(
9797
) -> None:
9898
if not para_sentences:
9999
return
100-
combined = " ".join(para_sentences)
101-
if len(combined.split()) < MIN_FRAGMENT_WORDS:
102-
return
103100
frag = self._create_paragraph_fragment(path, lines, para_start, end_line)
104101
if frag:
105102
fragments.append(frag)

src/treemapper/diffctx/utility.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,8 @@
176176

177177
_COMMENT_PREFIXES = ("#", "//", "*", "/*", "--", '"""', "'''", "<!--")
178178

179-
_EXTERNAL_IMPORT_RE = re.compile(
180-
r"""(?:import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]|from\s+(\S+)\s+import\s+(.+))""",
181-
)
179+
_JS_IMPORT_RE = re.compile(r"""import\s+\{([^}]+)\}\s+from\s+['"]([^'"]+)['"]""")
180+
_PY_IMPORT_RE = re.compile(r"""from\s+(\S+)\s+import\s+(.+)""")
182181

183182

184183
def _parse_import_names(names_str: str) -> set[str]:
@@ -193,12 +192,13 @@ def _parse_import_names(names_str: str) -> set[str]:
193192
def _collect_external_symbols(diff_text: str) -> frozenset[str]:
194193
symbols: set[str] = set()
195194
for line in _extract_changed_lines(diff_text):
196-
for m in _EXTERNAL_IMPORT_RE.finditer(line):
195+
for m in _JS_IMPORT_RE.finditer(line):
197196
js_names, js_source = m.group(1), m.group(2)
198-
py_module, py_names = m.group(3), m.group(4)
199-
if js_names and js_source and not js_source.startswith("."):
197+
if not js_source.startswith("."):
200198
symbols.update(_parse_import_names(js_names))
201-
if py_module and py_names and not py_module.startswith("."):
199+
for m in _PY_IMPORT_RE.finditer(line):
200+
py_module, py_names = m.group(1), m.group(2)
201+
if not py_module.startswith("."):
202202
symbols.update(_parse_import_names(py_names))
203203
return frozenset(symbols)
204204

0 commit comments

Comments
 (0)