Skip to content
This repository has been archived by the owner on Apr 1, 2022. It is now read-only.

Commit

Permalink
fix(maven): Parse platform specifiers in Maven package IDs (#329)
Browse files Browse the repository at this point in the history
  • Loading branch information
elldritch authored Aug 16, 2021
1 parent 4770c05 commit ff9dd3c
Show file tree
Hide file tree
Showing 4 changed files with 15,629 additions and 47 deletions.
6 changes: 5 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# Spectrometer Changelog

## v2.15.1

- Maven: Fixes an issue where dependencies with a platform specifier were not correctly parsed. ([#329](https://github.com/fossas/spectrometer/pull/329))

## v2.15.0

- Dart: Adds support for pub package manager. ([#313](https://github.com/fossas/spectrometer/pull/313))
- Modified DiscoveredProject's to include manifest file information (origin paths) ([#316](https://github.com/fossas/spectrometer/pull/316))
- Analyzed dependencies now report what file they were found in. ([#316](https://github.com/fossas/spectrometer/pull/316))

## v2.14.5

Expand Down
11 changes: 8 additions & 3 deletions src/Strategy/Maven/DepTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ data PackageId = PackageId
, artifactName :: Text
, artifactType :: Text
, artifactVersion :: Text
, artifactPlatform :: Maybe Text
, buildTag :: Maybe Text
}
deriving (Eq, Ord, Show)
Expand All @@ -185,7 +186,7 @@ data DotGraph = DotGraph
parseDotGraphs :: Parser [DotGraph]
parseDotGraphs = some $ do
root <- symbol "digraph" *> parseNode
edgeLists <- enclosed "{" "}" (many $ try parseGraphEntry)
edgeLists <- enclosed "{" "}" $ many $ try parseGraphEntry
pure $ DotGraph root edgeLists

parseGraphEntry :: Parser (PackageId, PackageId)
Expand All @@ -208,8 +209,12 @@ parseName input = combine parts
parts = Text.splitOn ":" input

combine :: [Text] -> m PackageId
combine [a, b, c, d, e] = pure . PackageId a b c d $ Just e
combine [a, b, c, d] = pure $ PackageId a b c d Nothing
combine [group, artifact, type', platform, version, scope] =
pure $ PackageId group artifact type' version (Just platform) (Just scope)
combine [group, artifact, type', version, scope] =
pure $ PackageId group artifact type' version Nothing (Just scope)
combine [group, artifact, type', version] =
pure $ PackageId group artifact type' version Nothing Nothing
combine items = fail $ toString $ "invalid identifier: " <> Text.intercalate ":" items

enclosed :: Text -> Text -> Parser a -> Parser a
Expand Down
Loading

0 comments on commit ff9dd3c

Please sign in to comment.