From 26333033eec608937b5d919201ecd7641c883ecb Mon Sep 17 00:00:00 2001 From: Scott Patten Date: Tue, 17 Sep 2024 15:14:32 -0700 Subject: [PATCH] fourmolu and cabal-fmt updates (#1471) * run fourmolu on all haskell files * format spectrometer.cabal --- src/App/Fossa/Analyze/ScanSummary.hs | 3 +-- src/App/Fossa/Config/Analyze.hs | 9 +++------ src/App/Fossa/Config/Common.hs | 6 ++---- src/App/Fossa/Config/Project.hs | 3 +-- src/App/Fossa/Config/Project/Edit.hs | 3 +-- src/App/Fossa/Config/ReleaseGroup.hs | 3 +-- src/App/Fossa/Config/ReleaseGroup/AddProjects.hs | 3 +-- src/App/Fossa/Config/ReleaseGroup/Create.hs | 3 +-- src/App/Fossa/Config/ReleaseGroup/CreateRelease.hs | 3 +-- src/App/Fossa/Config/ReleaseGroup/Delete.hs | 3 +-- src/App/Fossa/Config/ReleaseGroup/DeleteRelease.hs | 3 +-- src/App/Fossa/Reachability/Jar.hs | 3 +-- src/App/Fossa/Reachability/Upload.hs | 6 ++---- src/Container/OsRelease.hs | 3 +-- .../Carrier/FossaApiClient/Internal/FossaAPIV1.hs | 2 +- src/Data/Rpm/DbHeaderBlob/Internal.hs | 7 +++---- src/Effect/Exec.hs | 3 +-- src/Strategy/Cocoapods/PodfileLock.hs | 3 +-- src/Strategy/Maven/Plugin.hs | 3 +-- src/Strategy/Node.hs | 3 +-- src/Strategy/Node/YarnV1/YarnLock.hs | 3 +-- src/Strategy/R/Renv.hs | 12 +++++------- test/App/Fossa/Configuration/TelemetryConfigSpec.hs | 6 ++---- test/Container/RegistryApiSpec.hs | 3 +-- test/Test/MockApi.hs | 6 ++---- test/Test/MockDockerEngineApi.hs | 6 ++---- 26 files changed, 39 insertions(+), 72 deletions(-) diff --git a/src/App/Fossa/Analyze/ScanSummary.hs b/src/App/Fossa/Analyze/ScanSummary.hs index c87c5815f0..6ac87bafaf 100644 --- a/src/App/Fossa/Analyze/ScanSummary.hs +++ b/src/App/Fossa/Analyze/ScanSummary.hs @@ -222,8 +222,7 @@ summarize cfg endpointVersion (AnalysisScanResult dps vsi binary manualDeps dyna where reachabilitySummary = if null reachabilityAttempts - then - [] + then [] else summarizeReachability "Reachability analysis" reachabilityAttempts vsiResults = summarizeSrcUnit "vsi analysis" (Just (join . map vsiSourceUnits)) vsi projects = sort dps diff --git a/src/App/Fossa/Config/Analyze.hs b/src/App/Fossa/Config/Analyze.hs index de73320df7..2bccca0a54 100644 --- a/src/App/Fossa/Config/Analyze.hs +++ b/src/App/Fossa/Config/Analyze.hs @@ -555,8 +555,7 @@ mergeStandardOpts maybeConfig envvars cliOpts@AnalyzeCliOpts{..} = do <*> pure mode collectMavenScopeFilters :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> m MavenScopeFilters collectMavenScopeFilters maybeConfig = @@ -597,8 +596,7 @@ collectExperimental maybeCfg AnalyzeCliOpts{analyzeDynamicGoAnalysisType = goDyn shouldAnalyzePathDependencies collectVendoredDeps :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> AnalyzeCliOpts -> m VendoredDependencyOptions @@ -639,8 +637,7 @@ configGrepToGrep :: ConfigGrepEntry -> GrepEntry configGrepToGrep configGrep = GrepEntry (configGrepMatchCriteria configGrep) (configGrepName configGrep) collectScanDestination :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> AnalyzeCliOpts -> diff --git a/src/App/Fossa/Config/Common.hs b/src/App/Fossa/Config/Common.hs index 635171266a..0ef488e4c7 100644 --- a/src/App/Fossa/Config/Common.hs +++ b/src/App/Fossa/Config/Common.hs @@ -326,8 +326,7 @@ validateExists fp = Just (resolved :: Path Abs Dir) -> pure . SomeDir $ Abs resolved validateApiKey :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> CommonOpts -> @@ -347,8 +346,7 @@ validateApiKey maybeConfigFile EnvVars{envApiKey} CommonOpts{optAPIKey} = do else pure $ ApiKey textkey validateApiKeyGeneric :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> Maybe Text -> Maybe Text -> diff --git a/src/App/Fossa/Config/Project.hs b/src/App/Fossa/Config/Project.hs index 50f95b7c91..b567f20653 100644 --- a/src/App/Fossa/Config/Project.hs +++ b/src/App/Fossa/Config/Project.hs @@ -39,8 +39,7 @@ instance GetSeverity ProjectCommand where getSeverity (Edit (EditOpts{debug})) = if debug then SevDebug else SevInfo projectMergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> ProjectCommand -> diff --git a/src/App/Fossa/Config/Project/Edit.hs b/src/App/Fossa/Config/Project/Edit.hs index 447cedeb93..f02614f1d0 100644 --- a/src/App/Fossa/Config/Project/Edit.hs +++ b/src/App/Fossa/Config/Project/Edit.hs @@ -129,8 +129,7 @@ projectIdentiferOptions :: Parser (Maybe ProjectIdentifier) projectIdentiferOptions = optional (projectIdOptions <|> projectLocatorOptions) mergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> EditOpts -> diff --git a/src/App/Fossa/Config/ReleaseGroup.hs b/src/App/Fossa/Config/ReleaseGroup.hs index 68096929f7..2d69074536 100644 --- a/src/App/Fossa/Config/ReleaseGroup.hs +++ b/src/App/Fossa/Config/ReleaseGroup.hs @@ -58,8 +58,7 @@ instance GetSeverity ReleaseGroupCommand where DeleteRelease (DeleteReleaseOpts{DeleteRelease.releaseGroupCommon = ReleaseGroupCommonOpts{debug}}) -> if debug then SevDebug else SevInfo releaseGroupMergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> ReleaseGroupCommand -> diff --git a/src/App/Fossa/Config/ReleaseGroup/AddProjects.hs b/src/App/Fossa/Config/ReleaseGroup/AddProjects.hs index 64af26f17f..f990c1a5d3 100644 --- a/src/App/Fossa/Config/ReleaseGroup/AddProjects.hs +++ b/src/App/Fossa/Config/ReleaseGroup/AddProjects.hs @@ -66,8 +66,7 @@ cliParser = <*> optional (some (releaseGroupProjectOpts)) mergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> AddProjectsOpts -> diff --git a/src/App/Fossa/Config/ReleaseGroup/Create.hs b/src/App/Fossa/Config/ReleaseGroup/Create.hs index 9257eeeed2..addc1e126b 100644 --- a/src/App/Fossa/Config/ReleaseGroup/Create.hs +++ b/src/App/Fossa/Config/ReleaseGroup/Create.hs @@ -77,8 +77,7 @@ cliParser = <*> optional (some (strOption (applyFossaStyle <> long "team" <> short 'T' <> stringToHelpDoc "The team you want to assign to the FOSSA release group"))) mergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> CreateOpts -> diff --git a/src/App/Fossa/Config/ReleaseGroup/CreateRelease.hs b/src/App/Fossa/Config/ReleaseGroup/CreateRelease.hs index 2e88f5ef54..dfd7ab440e 100644 --- a/src/App/Fossa/Config/ReleaseGroup/CreateRelease.hs +++ b/src/App/Fossa/Config/ReleaseGroup/CreateRelease.hs @@ -64,8 +64,7 @@ cliParser = <*> optional (some (Common.releaseGroupProjectOpts)) mergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> CreateReleaseOpts -> diff --git a/src/App/Fossa/Config/ReleaseGroup/Delete.hs b/src/App/Fossa/Config/ReleaseGroup/Delete.hs index c07178eb05..308dbbb535 100644 --- a/src/App/Fossa/Config/ReleaseGroup/Delete.hs +++ b/src/App/Fossa/Config/ReleaseGroup/Delete.hs @@ -57,8 +57,7 @@ cliParser = <*> Common.releaseGroupTitleOpts mergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> DeleteOpts -> diff --git a/src/App/Fossa/Config/ReleaseGroup/DeleteRelease.hs b/src/App/Fossa/Config/ReleaseGroup/DeleteRelease.hs index 96e1d36e51..8e2239aebb 100644 --- a/src/App/Fossa/Config/ReleaseGroup/DeleteRelease.hs +++ b/src/App/Fossa/Config/ReleaseGroup/DeleteRelease.hs @@ -59,8 +59,7 @@ cliParser = <*> Common.releaseGroupReleaseTitleOpts mergeOpts :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => Maybe ConfigFile -> EnvVars -> DeleteReleaseOpts -> diff --git a/src/App/Fossa/Reachability/Jar.hs b/src/App/Fossa/Reachability/Jar.hs index a28cc0e85e..621f3fdfec 100644 --- a/src/App/Fossa/Reachability/Jar.hs +++ b/src/App/Fossa/Reachability/Jar.hs @@ -40,8 +40,7 @@ execJar :: CallGraphJarParser execJar = CallGraphJarParser{jar = $(embedFile' "scripts/jar-callgraph-1.0.2.jar")} withUnpackedPlugin :: - ( Has (Lift IO) sig m - ) => + (Has (Lift IO) sig m) => CallGraphJarParser -> (FP.FilePath -> m a) -> m a diff --git a/src/App/Fossa/Reachability/Upload.hs b/src/App/Fossa/Reachability/Upload.hs index e0e0ddbe2a..a2cec00b94 100644 --- a/src/App/Fossa/Reachability/Upload.hs +++ b/src/App/Fossa/Reachability/Upload.hs @@ -79,8 +79,7 @@ upload revision metadata units = do uploadBuildForReachability revision metadata units' uploadReachability :: - ( Has FossaApiClient sig m - ) => + (Has FossaApiClient sig m) => SourceUnitReachability -> m SourceUnitReachability uploadReachability unit = case callGraphAnalysis unit of @@ -91,8 +90,7 @@ uploadReachability unit = case callGraphAnalysis unit of pure $ unit{callGraphAnalysis = JarAnalysis updatedJars} uploadJarAnalysis :: - ( Has FossaApiClient sig m - ) => + (Has FossaApiClient sig m) => ParsedJar -> m ParsedJar uploadJarAnalysis jar = case parsedJarContent jar of diff --git a/src/Container/OsRelease.hs b/src/Container/OsRelease.hs index 331d0fe9ad..782094ad3b 100644 --- a/src/Container/OsRelease.hs +++ b/src/Container/OsRelease.hs @@ -167,8 +167,7 @@ osReleaseParser = do properties <- propertiesParser let nameId = asum - ( (`Map.lookup` properties) "ID" : [Just "linux"] -- We should default to linux as last resort per spec! - ) + ((`Map.lookup` properties) "ID" : [Just "linux"]) -- We should default to linux as last resort per spec! let versionId = Map.lookup "VERSION_ID" properties case (nameId, versionId) of diff --git a/src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs b/src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs index 9d79aa05d1..3ab2c97234 100644 --- a/src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs +++ b/src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs @@ -666,7 +666,7 @@ uploadNativeContainerScan apiOpts ProjectRevision{..} metadata scan = ( warnOnErr @Text "Container scan upload to new analysis service failed, falling back to core analysis." . errCtx ("Upload to new analysis service at " <> renderUrl sparkleAnalysisUrl) $ uploadScan sparkleAnalysisUrl scan - ) + ) <||> context "Upload to CORE analysis service" (uploadScan (containerUploadUrl Core baseUrl) scan) pure $ responseBody resp diff --git a/src/Data/Rpm/DbHeaderBlob/Internal.hs b/src/Data/Rpm/DbHeaderBlob/Internal.hs index 63f28aa372..b450e7b00b 100644 --- a/src/Data/Rpm/DbHeaderBlob/Internal.hs +++ b/src/Data/Rpm/DbHeaderBlob/Internal.hs @@ -305,10 +305,9 @@ readHeaderBlobTagData :: BLS.ByteString -> HeaderBlob -> Either String [TagValue readHeaderBlobTagData bs HeaderBlob{..} = do let firstEntry = NonEmpty.head entryMetadatas if tag firstEntry >= TagHeaderI18nTable - then - -- v3 entries, these seem to be uncommon. They are distinct from > v4 - -- entries in that they don't have a specialized region for v3 data, which - -- is why the function doesn't skip the first element of entryMetadatas + then -- v3 entries, these seem to be uncommon. They are distinct from > v4 + -- entries in that they don't have a specialized region for v3 data, which + -- is why the function doesn't skip the first element of entryMetadatas bimap ("Failed to parse legacy index entries: " <>) fst diff --git a/src/Effect/Exec.hs b/src/Effect/Exec.hs index 949c456d3c..bdcfbaff52 100644 --- a/src/Effect/Exec.hs +++ b/src/Effect/Exec.hs @@ -440,8 +440,7 @@ mkSingleCandidateAnalysisCommand cmd = CandidateAnalysisCommands (NE.singleton c -- It is also possible that no supported command is valid in the provided context; -- in such a case a diagnostics error is thrown in @m@. mkAnalysisCommand :: - ( CandidateCommandEffs sig m - ) => + (CandidateCommandEffs sig m) => CandidateAnalysisCommands -> Path Abs Dir -> [Text] -> diff --git a/src/Strategy/Cocoapods/PodfileLock.hs b/src/Strategy/Cocoapods/PodfileLock.hs index 6d90e08b6f..5db5c6fa80 100644 --- a/src/Strategy/Cocoapods/PodfileLock.hs +++ b/src/Strategy/Cocoapods/PodfileLock.hs @@ -291,8 +291,7 @@ buildGraph lockFilePath lockFile@PodLock{lockExternalSources} = do Text -> m Dependency readPodSubSpecSourceAt podSpecPath candidateSubSpec = context - ( "Trying to resolve (" <> candidateSubSpec <> "), It is potentially a vendored subspec of podspec at: " <> showT podSpecPath - ) + ("Trying to resolve (" <> candidateSubSpec <> "), It is potentially a vendored subspec of podspec at: " <> showT podSpecPath) $ do podSpecJson <- readPodSpecRaw podSpecPath diff --git a/src/Strategy/Maven/Plugin.hs b/src/Strategy/Maven/Plugin.hs index b6ecbd6405..64e19a8216 100644 --- a/src/Strategy/Maven/Plugin.hs +++ b/src/Strategy/Maven/Plugin.hs @@ -99,8 +99,7 @@ depGraphPluginLegacy = } withUnpackedPlugin :: - ( Has (Lift IO) sig m - ) => + (Has (Lift IO) sig m) => DepGraphPlugin -> (FP.FilePath -> m a) -> m a diff --git a/src/Strategy/Node.hs b/src/Strategy/Node.hs index 0f66c68897..78ea856d7c 100644 --- a/src/Strategy/Node.hs +++ b/src/Strategy/Node.hs @@ -136,8 +136,7 @@ collectManifests = walk' $ \_ _ files -> Just jsonFile -> pure ([Manifest jsonFile], skipJsFolders) mkProject :: - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => NodeProject -> m (DiscoveredProject NodeProject) mkProject project = do diff --git a/src/Strategy/Node/YarnV1/YarnLock.hs b/src/Strategy/Node/YarnV1/YarnLock.hs index 909d961c20..bfe19df504 100644 --- a/src/Strategy/Node/YarnV1/YarnLock.hs +++ b/src/Strategy/Node/YarnV1/YarnLock.hs @@ -71,8 +71,7 @@ data YarnV1Package = YarnV1Package buildGraph :: forall m sig. - ( Has Diagnostics sig m - ) => + (Has Diagnostics sig m) => YL.Lockfile -> FlatDeps -> m (Graphing Dependency) diff --git a/src/Strategy/R/Renv.hs b/src/Strategy/R/Renv.hs index 51e3258d62..38c664277b 100644 --- a/src/Strategy/R/Renv.hs +++ b/src/Strategy/R/Renv.hs @@ -166,15 +166,13 @@ buildGraph description renvLock = run . evalGrapher $ do let allDirectPkgs = allPkgNames description if null $ Map.toList allLockPackages - then - -- We have empty lock file, and only description manifest - -- create direct dependencies + then -- We have empty lock file, and only description manifest + -- create direct dependencies for_ (toList allDirectPkgs) $ \pkgReq -> do direct $ toCranDependency pkgReq - else - -- We have non-empty lock file, and description manifest - -- create complete dependency graph. Any dependency that - -- is mentioned in description is considered to be direct + else -- We have non-empty lock file, and description manifest + -- create complete dependency graph. Any dependency that + -- is mentioned in description is considered to be direct for_ (Map.toList allLockPackages) $ \(_, pkgMetadata) -> do let currentDep = toDependency allRepositories pkgMetadata let childDeps = diff --git a/test/App/Fossa/Configuration/TelemetryConfigSpec.hs b/test/App/Fossa/Configuration/TelemetryConfigSpec.hs index c94e3c4a54..64f1a97c14 100644 --- a/test/App/Fossa/Configuration/TelemetryConfigSpec.hs +++ b/test/App/Fossa/Configuration/TelemetryConfigSpec.hs @@ -185,8 +185,7 @@ spec = do it' "should set sink to nothing, when off scope is provided via configuration file" $ do sink <- collectTelemetrySink - ( Just defaultConfigFile{configTelemetry = Just $ ConfigTelemetry NoTelemetry} - ) + (Just defaultConfigFile{configTelemetry = Just $ ConfigTelemetry NoTelemetry}) defaultEnvVars noOpts sink `shouldBe'` Nothing @@ -194,8 +193,7 @@ spec = do it' "should set sink to endpoint, when full scope is provided via configuration file" $ do sink <- collectTelemetrySink - ( Just defaultConfigFile{configTelemetry = Just $ ConfigTelemetry FullTelemetry} - ) + (Just defaultConfigFile{configTelemetry = Just $ ConfigTelemetry FullTelemetry}) defaultEnvVars noOpts sink `shouldBe'` Just (TelemetrySinkToEndpoint (ApiOpts Nothing mockApiKey defaultApiPollDelay)) diff --git a/test/Container/RegistryApiSpec.hs b/test/Container/RegistryApiSpec.hs index 907c6ee6ae..40d2d8da49 100644 --- a/test/Container/RegistryApiSpec.hs +++ b/test/Container/RegistryApiSpec.hs @@ -61,8 +61,7 @@ parseAuthChallengeSpec = it "should parse basic auth challenge" $ wwwAuthenticateBasic - `shouldParseInto` ( BasicAuthChallenge "https://quay.io/v2/auth" - ) + `shouldParseInto` (BasicAuthChallenge "https://quay.io/v2/auth") registryApiSpec :: Spec registryApiSpec = diff --git a/test/Test/MockApi.hs b/test/Test/MockApi.hs index a225a8c6c1..f566fbaf35 100644 --- a/test/Test/MockApi.hs +++ b/test/Test/MockApi.hs @@ -255,8 +255,7 @@ matchExpectation _ _ = Nothing -- | Handles a request in the context of the mock API. handleRequest :: - ( Has (State [ApiExpectation]) sig m - ) => + (Has (State [ApiExpectation]) sig m) => forall a. FossaApiClientF a -> m (Maybe (ApiResult a)) @@ -310,8 +309,7 @@ runApiWithMock f = do assertUnexpectedCall req runMockApi :: - ( Has (Lift IO) sig m - ) => + (Has (Lift IO) sig m) => MockApiC m a -> m a runMockApi = diff --git a/test/Test/MockDockerEngineApi.hs b/test/Test/MockDockerEngineApi.hs index 92f883b406..17186d3c7c 100644 --- a/test/Test/MockDockerEngineApi.hs +++ b/test/Test/MockDockerEngineApi.hs @@ -121,8 +121,7 @@ matchExpectation a@(IsDockerEngineAccessible{}) (ApiExpectation _ requestExpecta matchExpectation _ _ = Nothing handleRequest :: - ( Has (State [ApiExpectation]) sig m - ) => + (Has (State [ApiExpectation]) sig m) => forall a. DockerEngineApiF a -> m (Maybe (ApiResult a)) @@ -171,8 +170,7 @@ runApiWithMock f = do assertUnexpectedCall req runMockApi :: - ( Has (Lift IO) sig m - ) => + (Has (Lift IO) sig m) => MockApiC m a -> m a runMockApi =