From 0d521f479e9e90347c3289641f3cb353cbcb19b4 Mon Sep 17 00:00:00 2001 From: Wesley Van Melle Date: Fri, 29 Oct 2021 10:16:55 -0700 Subject: [PATCH] Don't let errors escape from nodeJS discovery (#424) * Don't let errors escape from nodeJS discovery * Use return early method instead * update changelog --- Changelog.md | 6 +++++- src/App/Fossa/Analyze.hs | 1 - src/Strategy/Node.hs | 10 +++++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Changelog.md b/Changelog.md index 4712827d9..062852f36 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Spectrometer Changelog +## v2.19.1 + +- Fixes an issue where nodeJS errors were reported when no NodeJS project were discovered. ([#424](https://github.com/fossas/spectrometer/pull/424)) + ## v2.19.0 - Adds support for `fossa analyze --include-unused-deps`, which prevents filtering out non-production dependencies. ([#412](https://github.com/fossas/spectrometer/pull/412)) @@ -7,7 +11,7 @@ - Npm: Adds support for workspaces. ([#374](https://github.com/fossas/spectrometer/pull/374)) - Npm: Removes unreliable `npm ls`-based analysis tactic. ([#374](https://github.com/fossas/spectrometer/pull/374)) - `fossa-deps`: Adds support for `bower`-type in `referenced-dependencies`. ([#406](https://github.com/fossas/spectrometer/pull/406)) -- Monorepo: Chunk AOSP files when uploading ([#421](https://github.com/fossas/spectrometer/pull/421)). +- Monorepo: Chunk AOSP files when uploading ([#421](https://github.com/fossas/spectrometer/pull/421)). - Monorepo: Don't fail on files that are filtered during expansion ([#421](https://github.com/fossas/spectrometer/pull/421)). ## v2.18.1 diff --git a/src/App/Fossa/Analyze.hs b/src/App/Fossa/Analyze.hs index 37e2b151d..be0091a45 100644 --- a/src/App/Fossa/Analyze.hs +++ b/src/App/Fossa/Analyze.hs @@ -354,7 +354,6 @@ analyze (BaseDir basedir) destination override unpackArchives jsonOutput include Diag.withResult SevError res (const (pure ())) let filteredProjects = filterProjects (BaseDir basedir) projectResults - logInfo ("Include-all option is set to: " <> pretty (fromFlag IncludeAll includeAll)) -- Need to check if vendored is empty as well, even if its a boolean that vendoredDeps exist case checkForEmptyUpload includeAll projectResults filteredProjects additionalSourceUnits of diff --git a/src/Strategy/Node.hs b/src/Strategy/Node.hs index c0ac1d2cd..50aadafcf 100644 --- a/src/Strategy/Node.hs +++ b/src/Strategy/Node.hs @@ -86,9 +86,13 @@ discover :: discover dir = context "NodeJS" $ do manifestList <- context "Finding nodejs projects" $ collectManifests dir manifestMap <- context "Reading package.json files" $ (Map.fromList . catMaybes) <$> traverse loadPackage manifestList - globalGraph <- context "Building global workspace graph" $ pure $ buildManifestGraph manifestMap - graphs <- context "Splitting global graph into chunks" $ fromMaybeText "" $ splitGraph globalGraph - context "Converting graphs to analysis targets" $ traverse (mkProject <=< identifyProjectType) graphs + if Map.null manifestMap + then -- If the map is empty, we found no JS projects, we return early. + pure [] + else do + globalGraph <- context "Building global workspace graph" $ pure $ buildManifestGraph manifestMap + graphs <- context "Splitting global graph into chunks" $ fromMaybeText "" $ splitGraph globalGraph + context "Converting graphs to analysis targets" $ traverse (mkProject <=< identifyProjectType) graphs collectManifests :: (Has ReadFS sig m, Has Diagnostics sig m) => Path Abs Dir -> m [Manifest] collectManifests = walk' $ \_ _ files ->