Skip to content

Commit de12f6a

Browse files
authored
chore: correctly parse and differentiate between indirect & direct dependencies in go.mod files (#416)
1 parent b8af0f8 commit de12f6a

19 files changed

+3513
-4529
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ unit-tests-result.json
99
build
1010
target
1111
.npmrc
12-
src/providers/tree-sitter-requirements.wasm
12+
src/providers/*.wasm

README.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,11 @@ Excluding a package from any analysis can be achieved by marking the package for
287287
]
288288
}
289289
```
290+
</li>
291+
292+
<li>
293+
<em>Golang</em> users can add in go.mod a comment with <code>// exhortignore</code> next to the package to be ignored, or to "piggyback" on existing comment ( e.g - <code>// indirect</code>), for example:
290294
291-
<em>Golang</em> users can add in go.mod a comment with //exhortignore next to the package to be ignored, or to "piggyback" on existing comment ( e.g - //indirect) , for example:
292295
```go
293296
module github.com/trustify-da/SaaSi/deployer
294297
@@ -297,22 +300,28 @@ go 1.19
297300
require (
298301
github.com/gin-gonic/gin v1.9.1
299302
github.com/google/uuid v1.1.2
300-
github.com/jessevdk/go-flags v1.5.0 //exhortignore
303+
github.com/jessevdk/go-flags v1.5.0 // exhortignore
301304
github.com/kr/pretty v0.3.1
302305
gopkg.in/yaml.v2 v2.4.0
303306
k8s.io/apimachinery v0.26.1
304307
k8s.io/client-go v0.26.1
305308
)
306309
307310
require (
308-
github.com/davecgh/go-spew v1.1.1 // indirect exhortignore
311+
github.com/davecgh/go-spew v1.1.1 // indirect; exhortignore
309312
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
310-
github.com/go-logr/logr v1.2.3 // indirect //exhortignore
313+
github.com/go-logr/logr v1.2.3 // indirect; exhortignore
311314
312315
)
313316
```
314317
318+
<b>NOTE</b>: It is important to format <code>exhortignore</code> markers on indirect dependencies as shown above, otherwise the Go tooling (as well as this library) may incorrectly parse dependencies marked as indirect as being direct dependencies instead.
319+
</li>
320+
321+
322+
<li>
315323
<em>Python pip</em> users can add in requirements.txt a comment with #exhortignore(or # exhortignore) to the right of the same artifact to be ignored, for example:
324+
316325
```properties
317326
anyio==3.6.2
318327
asgiref==3.4.1
@@ -343,11 +352,14 @@ Werkzeug==2.0.3
343352
zipp==3.6.0
344353
345354
```
355+
</li>
346356
357+
<li>
347358
<em>Gradle</em> users can add in build.gradle a comment with //exhortignore next to the package to be ignored:
359+
348360
```build.gradle
349361
plugins {
350-
id 'java'
362+
id 'java'
351363
}
352364
353365
group = 'groupName'
@@ -381,7 +393,6 @@ log = "0.4" # trustify-da-ignore
381393
382394
All of the 6 above examples are valid for marking a package to be ignored
383395
</li>
384-
385396
</ul>
386397
387398
<h3>Customization</h3>

0 commit comments

Comments
 (0)