Skip to content

Go import blocks: trailing comments on kept lines can still credit a commented-out package #88

Description

@jpbelmo

Sibling of the bug fixed in #85, found during its review. A kept line inside a Go import block with a trailing comment still feeds both quoted strings to the path regex:

import (
    "fmt" // "github.com/spf13/cobra"
)

credits github.com/spf13/cobra even though it only exists inside the comment. #85 fixed whole-line comments inside blocks; this is the same class at a different position. The fix needs to strip the trailing-comment portion of kept block lines before the path regex runs (mind // inside quoted strings — Go import paths can't contain spaces, which helps).

Deliverable: the guard + positive/negative regression tests in test/import-detect.test.ts, same style as #85's. @eeshsaxena has first claim if wanted (their find, effectively); open to anyone otherwise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    detectionSkill/signature detection (Tier 1, Tier 2, or the structural tier)up-for-grabsStandalone, well-scoped, and ready for a first-time contributor

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions