Class: Dependabot::Sbt::FileParser

Inherits:
FileParsers::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/sbt/file_parser.rb,
lib/dependabot/sbt/file_parser/repositories_finder.rb,
lib/dependabot/sbt/file_parser/property_value_finder.rb

Defined Under Namespace

Classes: PropertyValueFinder, RepositoriesFinder

Constant Summary collapse

BUILD_SBT_FILENAME =
"build.sbt"
BUILD_PROPERTIES_FILENAME =
"project/build.properties"
IDENT_OR_DOTTED =

Matches a simple identifier or dotted reference (e.g. myVal, V.scala212)

T.let(
  "[a-zA-Z_]\\w*(?:\\.[a-zA-Z_]\\w*)*",
  String
)
LIBRARY_DEP_REGEX =

“org” % “artifact” % “version” or “org” %% “artifact” % “version” Optionally followed by % “scope” (e.g. % “test”, % “provided”)

T.let(
  /"(?<group>[^"]+)"\s+(?<op>%%?)\s+"(?<artifact>[^"]+)"\s+%\s+"(?<version>[^"]+)"(?:\s+%\s+"[^"]*")*/,
  Regexp
)
VAL_REF_DEP_REGEX =

“org” % “artifact” % valName or “org” %% “artifact” % valName Also handles dotted references like Object.member

T.let(
  /"(?<group>[^"]+)"\s+(?<op>%%?)\s+"(?<artifact>[^"]+)"\s+%\s+(?<val_name>[a-zA-Z_]\w*(?:\.[a-zA-Z_]\w*)*)/,
  Regexp
)
PLUGIN_DEP_REGEX =

addSbtPlugin(“org” % “name” % “version”)

T.let(
  /addSbtPlugin\(\s*"(?<group>[^"]+)"\s+%\s+"(?<artifact>[^"]+)"\s+%\s+"(?<version>[^"]+)"\s*\)/,
  Regexp
)
PLUGIN_VAL_REF_REGEX =

addSbtPlugin(“org” % “name” % valName) Also handles dotted references like Object.member

T.let(
  /addSbtPlugin\(\s*"(?<group>[^"]+)"\s+%\s+"(?<artifact>[^"]+)"\s+%\s+(?<val_name>#{IDENT_OR_DOTTED})\s*\)/,
  Regexp
)
SBT_VERSION_REGEX =

sbt.version=1.x.y in build.properties

T.let(
  /\Asbt\.version\s*=\s*(?<version>.+)\z/,
  Regexp
)
SCALA_VERSION_REGEX =

scalaVersion := “2.13.12” or ThisBuild / scalaVersion := “2.13.12” Also: scalaVersion in ThisBuild := “2.13.12” (older SBT syntax)

T.let(
  %r{(?:ThisBuild\s*/\s*)?(?:scalaVersion\s+in\s+ThisBuild|scalaVersion)\s*:=\s*"(?<version>[^"]+)"},
  Regexp
)
SCALA_VERSION_VAL_REGEX =

scalaVersion := valRef or scalaVersion in ThisBuild := V.scala212

T.let(
  %r{(?:ThisBuild\s*/\s*)?(?:scalaVersion\s+in\s+ThisBuild|scalaVersion)\s*:=\s*(?<val_name>#{IDENT_OR_DOTTED})},
  Regexp
)

Instance Method Summary collapse

Instance Method Details

#ecosystemObject



102
103
104
105
106
107
108
109
110
111
# File 'lib/dependabot/sbt/file_parser.rb', line 102

def ecosystem
  @ecosystem ||= T.let(
    Ecosystem.new(
      name: ECOSYSTEM,
      package_manager: package_manager,
      language: language
    ),
    T.nilable(Ecosystem)
  )
end

#parseObject



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/dependabot/sbt/file_parser.rb', line 79

def parse
  dependency_set = DependencySet.new

  sbt_files.each do |buildfile|
    dependency_set += buildfile_dependencies(buildfile)
  end

  scala_build_files.each do |buildfile|
    dependency_set += buildfile_dependencies(buildfile)
  end

  build_properties_files.each do |properties_file|
    dependency_set += sbt_version_dependency(properties_file)
  end

  sbt_files.each do |buildfile|
    dependency_set += scala_version_dependency(buildfile)
  end

  dependency_set.dependencies
end