Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/plugins/analysis/linter/code/source_code_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import pydantic
from docker.types import Mount
from pydantic import Field
from semver import Version

from analysis.plugin import AnalysisPluginV0
from helperFunctions.docker import run_docker_container
Expand Down Expand Up @@ -35,7 +36,7 @@ class Schema(pydantic.BaseModel):
class Issue(pydantic.BaseModel):
"""A linting issue."""

symbol: str = Field(
symbol: Optional[str] = Field(
description=(
"An identifier for the linting type. E.g. 'unused-import' (pylint).\n"
'Note that this field is linter specific.'
Expand Down Expand Up @@ -65,9 +66,9 @@ def __init__(self):
metadata=AnalysisPluginV0.MetaData(
name='source_code_analysis',
description='This plugin implements static code analysis for multiple scripting languages',
version='0.7.1',
version=Version(0, 7, 3),
Schema=AnalysisPlugin.Schema,
mime_whitelist=['text/'],
mime_whitelist=['text/', 'application/javascript'],
),
)

Expand Down
9 changes: 7 additions & 2 deletions src/plugins/analysis/linter/internal/linters.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,15 @@ def run_eslint(file_path):
output_json = json.loads(result.stdout)

issues = []
# As we only ever analyse one file use output_json[0]
# As we only ever analyze one file use output_json[0]
for msg in output_json[0]['messages']:
issues.append(
{'line': msg['line'], 'column': msg['column'], 'message': msg['message'], 'symbol': msg['ruleId']}
{
'line': msg['line'],
'column': msg['column'],
'message': msg['message'],
'symbol': msg['ruleId'] or 'N/A', # ruleId can be None if there is a syntax error
}
)

return issues
Expand Down