Class: Dependabot::GoModules::DependencyGrapher

Inherits:
DependencyGraphers::Base
  • Object
show all
Defined in:
lib/dependabot/go_modules/dependency_grapher.rb

Constant Summary collapse

GO_MOD_GRAPH_LINE_REGEX =

Used to capture output from ‘go mod graph`

The parent and child are space-separated and we process one line at a time.

Example output:

github.com/dependabot/core-test rsc.io/sampler@v1.3.0
rsc.io/sampler@v1.3.0 golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c
<---parent--->        <----child------>
T.let(/^(?<parent>[^@\s]+)@?[^\s]*\s(?<child>[^@\s]+)/, Regexp)

Instance Method Summary collapse

Instance Method Details

#relevant_dependency_fileObject

Raises:

  • (DependabotError)


24
25
26
27
28
29
30
# File 'lib/dependabot/go_modules/dependency_grapher.rb', line 24

def relevant_dependency_file
  # This cannot realistically happen as the parser will throw a runtime error on init without a go_mod file,
  # but this will avoid surprises if anything changes.
  raise DependabotError, "No go.mod present in dependency files." unless go_mod

  T.must(go_mod)
end