Skip to content

Commit

Permalink
fourmolu and cabal-fmt updates (#1471)
Browse files Browse the repository at this point in the history
* run fourmolu on all haskell files
* format spectrometer.cabal
  • Loading branch information
spatten authored Sep 17, 2024
1 parent 3a00319 commit 2633303
Show file tree
Hide file tree
Showing 26 changed files with 39 additions and 72 deletions.
3 changes: 1 addition & 2 deletions src/App/Fossa/Analyze/ScanSummary.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 3 additions & 6 deletions src/App/Fossa/Config/Analyze.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -597,8 +596,7 @@ collectExperimental maybeCfg AnalyzeCliOpts{analyzeDynamicGoAnalysisType = goDyn
shouldAnalyzePathDependencies

collectVendoredDeps ::
( Has Diagnostics sig m
) =>
(Has Diagnostics sig m) =>
Maybe ConfigFile ->
AnalyzeCliOpts ->
m VendoredDependencyOptions
Expand Down Expand Up @@ -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 ->
Expand Down
6 changes: 2 additions & 4 deletions src/App/Fossa/Config/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand All @@ -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 ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/Project.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/Project/Edit.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/ReleaseGroup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/ReleaseGroup/AddProjects.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ cliParser =
<*> optional (some (releaseGroupProjectOpts))

mergeOpts ::
( Has Diagnostics sig m
) =>
(Has Diagnostics sig m) =>
Maybe ConfigFile ->
EnvVars ->
AddProjectsOpts ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/ReleaseGroup/Create.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/ReleaseGroup/CreateRelease.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ cliParser =
<*> optional (some (Common.releaseGroupProjectOpts))

mergeOpts ::
( Has Diagnostics sig m
) =>
(Has Diagnostics sig m) =>
Maybe ConfigFile ->
EnvVars ->
CreateReleaseOpts ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/ReleaseGroup/Delete.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ cliParser =
<*> Common.releaseGroupTitleOpts

mergeOpts ::
( Has Diagnostics sig m
) =>
(Has Diagnostics sig m) =>
Maybe ConfigFile ->
EnvVars ->
DeleteOpts ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Config/ReleaseGroup/DeleteRelease.hs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ cliParser =
<*> Common.releaseGroupReleaseTitleOpts

mergeOpts ::
( Has Diagnostics sig m
) =>
(Has Diagnostics sig m) =>
Maybe ConfigFile ->
EnvVars ->
DeleteReleaseOpts ->
Expand Down
3 changes: 1 addition & 2 deletions src/App/Fossa/Reachability/Jar.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/App/Fossa/Reachability/Upload.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Container/OsRelease.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/Data/Rpm/DbHeaderBlob/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Effect/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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] ->
Expand Down
3 changes: 1 addition & 2 deletions src/Strategy/Cocoapods/PodfileLock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions src/Strategy/Maven/Plugin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ depGraphPluginLegacy =
}

withUnpackedPlugin ::
( Has (Lift IO) sig m
) =>
(Has (Lift IO) sig m) =>
DepGraphPlugin ->
(FP.FilePath -> m a) ->
m a
Expand Down
3 changes: 1 addition & 2 deletions src/Strategy/Node.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/Strategy/Node/YarnV1/YarnLock.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 5 additions & 7 deletions src/Strategy/R/Renv.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
6 changes: 2 additions & 4 deletions test/App/Fossa/Configuration/TelemetryConfigSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,15 @@ 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

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))
3 changes: 1 addition & 2 deletions test/Container/RegistryApiSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
6 changes: 2 additions & 4 deletions test/Test/MockApi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 =
Expand Down
6 changes: 2 additions & 4 deletions test/Test/MockDockerEngineApi.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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 =
Expand Down

0 comments on commit 2633303

Please sign in to comment.