Skip to content

OnelineParserInvalidWarning when using spaces as separators in comments #51

@patdhlk

Description

@patdhlk

Description

The parser (analyse/oneline_parser.py) does not correctly handle oneline comments when a space is used as a separator immediately following the tag.

Example: If the comment is @implementation , the parser splits the string at the space. Because the captured string starts with a space, the split operation creates an empty string as the first element: ['', '', '', ...]

This results in one more element than specified in the codelinks.toml configuration, causing the parser to throw an OnelineParserInvalidWarning.

Technical Details

File: analyse/oneline_parser.py

Lines: 66-71 (splitting logic) and Line 56 (string extraction).

Root Cause: Line 56 (string = oneline[start_idx:end_idx]) captures the string including the leading space. When line 66 splits this string, the leading space generates an unwanted empty string index 0.

Proposed Solution

To fix this, we should sanitize the string before splitting.

Preferred Fix: Apply .strip() to the string variable before the split operation.

This removes the leading space causing the issue.

This is safer than modifying the slice index (e.g., start_idx+1) because it remains robust even if a user writes a comment without a space (e.g., @ ).

Alternative (Not recommended): Changing line 56 to string = oneline[start_idx+1:end_idx]. This is risky as it assumes a separator always exists.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions