This commit is contained in:
@@ -2,9 +2,8 @@ from __future__ import annotations
|
||||
|
||||
import xml.etree.ElementTree as ET
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from depaudit.parsers import Parser, ParsedManifest, Dependency
|
||||
from depaudit.parsers import Parser, ParsedManifest
|
||||
|
||||
|
||||
class JavaParser(Parser):
|
||||
@@ -44,7 +43,7 @@ class JavaParser(Parser):
|
||||
version = root.find("version")
|
||||
|
||||
if group_id is not None and artifact_id is not None:
|
||||
manifest.project_name = group_id.text + "/" + artifact_id.text
|
||||
manifest.project_name = (group_id.text or "") + "/" + (artifact_id.text or "")
|
||||
else:
|
||||
manifest.project_name = None
|
||||
manifest.project_version = version.text if version is not None else None
|
||||
@@ -125,7 +124,7 @@ class JavaParser(Parser):
|
||||
if version_match:
|
||||
manifest.project_version = version_match
|
||||
|
||||
dep_pattern = r"(?:implementation|api|compileOnly|runtimeOnly|testImplementation|testCompileOnly)\s*[\(\"']?\s*([^\s:\'\")]+)\s*:\s*([^\s:\'\")]+)\s*:\s*([^\s:\'\")]+)"
|
||||
dep_pattern = r"(?:implementation|api|compileOnly|runtimeOnly|testImplementation|testCompileOnly)\s*[\(\ \"']?\s*([^\s:\'\")]+)\s*:\s*([^\s:\'\")]+)\s*:\s*([^\s:\'\")]+)"
|
||||
for match in re.finditer(dep_pattern, content):
|
||||
group = match.group(1)
|
||||
name = match.group(2)
|
||||
@@ -138,8 +137,8 @@ class JavaParser(Parser):
|
||||
def _extract_gradle_value(self, content: str, key: str) -> str | None:
|
||||
import re
|
||||
patterns = [
|
||||
key + "\s*=\s*["']([^"\']+)["']",
|
||||
key + "\s*=\s*([^\s]+)",
|
||||
key + r"\s*=\s*[\"\']([^\"\']+)[\"\']",
|
||||
key + r"\s*=\s*([^\s]+)",
|
||||
]
|
||||
for pattern in patterns:
|
||||
match = re.search(pattern, content)
|
||||
|
||||
Reference in New Issue
Block a user