microsoft / microsoft/component-detection

Go/GoWithReplace skipping over go.mod files in child directories

Open
#1,218 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
553
Forks
135
Avg merge
20h 58m
Merged PRs (30d)
6

Description

If you have a file structure like this:

/
- Path1/
- - go.mod
- - go.sum
- - ...
- Path2/
- - go.mod
- - go.sum
- - ...
- go.mod
- go.sum

The internal go.mod files are skipped due to these lines: https://github.com/microsoft/component-detection/blob/80146ce1b940c4075156165f6d677b68d7e368f7/src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs#L157

if (this.projectRoots.Any(path => projectRootDirectory.FullName.StartsWith(path)))
        {
            return;
        }

We would expect the root go.mod to have all the internal references, but in cases where the internal directories are not referenced by the root mod then components are being skipped.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/Microsoft.ComponentDetection.Detectors/go/GoComponentDetector.cs around line 157 and inspect how projectRoots causes child go.mod files to be skipped. Reproduce the shown nested-module layout, then verify that internal go.mod files are detected when the root go.mod does not reference them.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, go
Domain
devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.