Skip to content

Commit

Permalink
Revert the required newline before .: across the codebase
Browse files Browse the repository at this point in the history
  • Loading branch information
jssblck committed May 1, 2024
1 parent fcbc15c commit ab05c1e
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 134 deletions.
6 changes: 2 additions & 4 deletions src/App/Fossa/Lernie/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ instance ToJSON GrepEntry where
instance FromJSON GrepEntry where
parseJSON = withObject "GrepEntry" $ \obj ->
GrepEntry
<$> obj
.: "matchCriteria"
<*> obj
.: "name"
<$> obj .: "matchCriteria"
<*> obj .: "name"

data LernieConfig = LernieConfig
{ rootDir :: Path Abs Dir
Expand Down
12 changes: 4 additions & 8 deletions src/App/Fossa/ManualDeps.hs
Original file line number Diff line number Diff line change
Expand Up @@ -513,8 +513,7 @@ instance FromJSON CustomDependency where
<$> (obj `neText` "name")
<*> (unTextLike <$> obj `neText` "version")
<*> (obj `neText` "license")
<*> obj
.:? "metadata"
<*> obj .:? "metadata"
<* forbidMembers "custom dependencies" ["type", "path", "url"] obj

instance FromJSON RemoteDependency where
Expand All @@ -523,8 +522,7 @@ instance FromJSON RemoteDependency where
<$> (obj `neText` "name")
<*> (unTextLike <$> obj `neText` "version")
<*> (obj `neText` "url")
<*> obj
.:? "metadata"
<*> obj .:? "metadata"
<* forbidMembers "remote dependencies" ["license", "path", "type"] obj

validateRemoteDep :: (Has Diagnostics sig m) => RemoteDependency -> Organization -> m RemoteDependency
Expand Down Expand Up @@ -582,10 +580,8 @@ instance ToDiagnostic RemoteDepLengthIsGtThanAllowed where
instance FromJSON DependencyMetadata where
parseJSON = withObject "metadata" $ \obj ->
DependencyMetadata
<$> obj
.:? "description"
<*> obj
.:? "homepage"
<$> obj .:? "description"
<*> obj .:? "homepage"
<* forbidMembers "metadata" ["url"] obj

-- Parse supported dependency types into their respective type or return Nothing.
Expand Down
6 changes: 2 additions & 4 deletions src/App/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ instance ToJSON ReleaseGroupMetadata where
instance FromJSON ReleaseGroupMetadata where
parseJSON = withObject "ReleaseGroupMetadata" $ \obj ->
ReleaseGroupMetadata
<$> obj
.: "name"
<*> obj
.: "release"
<$> obj .: "name"
<*> obj .: "release"

data ProjectRevision = ProjectRevision
{ projectName :: Text
Expand Down
6 changes: 2 additions & 4 deletions src/Control/Carrier/FossaApiClient/Internal/FossaAPIV1.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,8 @@ data FossaPublicFacingError = FossaPublicFacingError
instance FromJSON FossaPublicFacingError where
parseJSON = withObject "FossaPublicFacingError" $ \v ->
FossaPublicFacingError
<$> v
.: "message"
<*> v
.: "uuid"
<$> v .: "message"
<*> v .: "uuid"

newtype FossaReq m a = FossaReq {unFossaReq :: m a}
deriving (Functor, Applicative, Monad, Algebra sig)
Expand Down
6 changes: 2 additions & 4 deletions src/Effect/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,8 @@ instance RecordableValue CmdFailure
instance FromJSON CmdFailure where
parseJSON = withObject "CmdFailure" $ \obj ->
CmdFailure
<$> obj
.: "cmdFailureCmd"
<*> obj
.: "cmdFailureDir"
<$> obj .: "cmdFailureCmd"
<*> obj .: "cmdFailureDir"
<*> (obj .: "cmdFailureExit" >>= fromRecordedValue)
<*> (obj .: "cmdFailureStdout" >>= fromRecordedValue)
<*> (obj .: "cmdFailureStderr" >>= fromRecordedValue)
Expand Down
153 changes: 45 additions & 108 deletions src/Fossa/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,9 @@ newtype BuildTask = BuildTask
instance FromJSON Build where
parseJSON = withObject "Build" $ \obj ->
Build
<$> obj
.: "id"
<*> obj
.:? "error"
<*> obj
.: "task"
<$> obj .: "id"
<*> obj .:? "error"
<*> obj .: "task"

instance FromJSON BuildTask where
parseJSON = withObject "BuildTask" $ \obj ->
Expand Down Expand Up @@ -331,15 +328,10 @@ newtype IssueRule = IssueRule
instance FromJSON Issues where
parseJSON = withObject "Issues" $ \obj ->
Issues
<$> obj
.: "count"
<*> obj
.:? "issues"
.!= []
<*> obj
.: "status"
<*> obj
.:? "summary"
<$> obj .: "count"
<*> obj .:? "issues" .!= []
<*> obj .: "status"
<*> obj .:? "summary"

instance ToJSON Issues where
toJSON Issues{..} =
Expand All @@ -353,11 +345,8 @@ instance ToJSON Issues where
instance FromJSON IssuesSummary where
parseJSON = withObject "IssuesSummary" $ \obj ->
IssuesSummary
<$> obj
.: "revision"
<*> obj
.:? "targets"
.!= []
<$> obj .: "revision"
<*> obj .:? "targets" .!= []

instance ToJSON IssuesSummary where
toJSON IssuesSummary{..} =
Expand All @@ -369,12 +358,9 @@ instance ToJSON IssuesSummary where
instance FromJSON IssueSummaryRevision where
parseJSON = withObject "IssueSummaryRevision" $ \obj ->
IssueSummaryRevision
<$> obj
.: "projectTitle"
<*> obj
.: "projectRevision"
<*> obj
.:? "isPublic"
<$> obj .: "projectTitle"
<*> obj .: "projectRevision"
<*> obj .:? "isPublic"

instance ToJSON IssueSummaryRevision where
toJSON IssueSummaryRevision{..} =
Expand All @@ -387,10 +373,8 @@ instance ToJSON IssueSummaryRevision where
instance FromJSON IssueSummaryTarget where
parseJSON = withObject "IssueSummaryTarget" $ \obj ->
IssueSummaryTarget
<$> obj
.: "type"
<*> obj
.: "originPaths"
<$> obj .: "type"
<*> obj .: "originPaths"

instance ToJSON IssueSummaryTarget where
toJSON IssueSummaryTarget{..} =
Expand All @@ -402,27 +386,16 @@ instance ToJSON IssueSummaryTarget where
instance FromJSON Issue where
parseJSON = withObject "Issue" $ \obj ->
Issue
<$> obj
.: "id"
<*> obj
.:? "priorityString"
<*> obj
.: "resolved"
<*> obj
.:? "revisionId"
.!= "unknown project"
<*> obj
.: "type"
<*> obj
.:? "rule"
<*> obj
.:? "license"
<*> obj
.:? "issueDashURL"
<*> obj
.:? "cve"
<*> obj
.:? "fixedIn"
<$> obj .: "id"
<*> obj .:? "priorityString"
<*> obj .: "resolved"
<*> obj .:? "revisionId" .!= "unknown project"
<*> obj .: "type"
<*> obj .:? "rule"
<*> obj .:? "license"
<*> obj .:? "issueDashURL"
<*> obj .:? "cve"
<*> obj .:? "fixedIn"

instance ToJSON Issue where
toJSON Issue{..} =
Expand Down Expand Up @@ -530,53 +503,22 @@ blankOrganization =
instance FromJSON Organization where
parseJSON = withObject "Organization" $ \obj ->
Organization
<$> obj
.: "organizationId"
<*> obj
.:? "usesSAML"
.!= False
<*> obj
.:? "supportsCliLicenseScanning"
.!= False
<*> obj
.:? "supportsAnalyzedRevisionsQuery"
.!= False
<*> obj
.:? "defaultVendoredDependencyScanType"
.!= CLILicenseScan
<*> obj
.:? "supportsIssueDiffs"
.!= False
<*> obj
.:? "supportsNativeContainerScans"
.!= False
<*> obj
.:? "supportsDependenciesCachePolling"
.!= False
<*> obj
.:? "requireFullFileUploads"
.!= False
<*> obj
.:? "defaultToFirstPartyScans"
.!= False
<*> obj
.:? "supportsPathDependency"
.!= False
<*> obj
.:? "supportsFirstPartyScans"
.!= False
<*> obj
.:? "customLicenseScanConfigs"
.!= []
<*> obj
.:? "supportsReachability"
.!= False
<*> obj
.:? "supportsPreflightChecks"
.!= False
<*> obj
.:? "subscription"
.!= Free
<$> obj .: "organizationId"
<*> obj .:? "usesSAML" .!= False
<*> obj .:? "supportsCliLicenseScanning" .!= False
<*> obj .:? "supportsAnalyzedRevisionsQuery" .!= False
<*> obj .:? "defaultVendoredDependencyScanType" .!= CLILicenseScan
<*> obj .:? "supportsIssueDiffs" .!= False
<*> obj .:? "supportsNativeContainerScans" .!= False
<*> obj .:? "supportsDependenciesCachePolling" .!= False
<*> obj .:? "requireFullFileUploads" .!= False
<*> obj .:? "defaultToFirstPartyScans" .!= False
<*> obj .:? "supportsPathDependency" .!= False
<*> obj .:? "supportsFirstPartyScans" .!= False
<*> obj .:? "customLicenseScanConfigs" .!= []
<*> obj .:? "supportsReachability" .!= False
<*> obj .:? "supportsPreflightChecks" .!= False
<*> obj .:? "subscription" .!= Free

data TokenType
= Push
Expand All @@ -589,8 +531,7 @@ newtype TokenTypeResponse = TokenTypeResponse {tokenType :: TokenType}
instance FromJSON TokenTypeResponse where
parseJSON = withObject "TokenTypeResponse" $ \obj ->
TokenTypeResponse
<$> obj
.: "tokenType"
<$> obj .: "tokenType"

instance FromJSON TokenType where
parseJSON = withText "TokenType" $ \case
Expand Down Expand Up @@ -651,12 +592,9 @@ data Project = Project
instance FromJSON Project where
parseJSON = withObject "Project" $ \obj ->
Project
<$> obj
.: "id"
<*> obj
.: "title"
<*> obj
.: "isMonorepo"
<$> obj .: "id"
<*> obj .: "title"
<*> obj .: "isMonorepo"

data UploadResponse = UploadResponse
{ uploadLocator :: Locator
Expand Down Expand Up @@ -684,8 +622,7 @@ newtype RevisionDependencyCache = RevisionDependencyCache {status :: RevisionDep
instance FromJSON RevisionDependencyCache where
parseJSON = withObject "RevisionDependencyCache" $ \obj ->
RevisionDependencyCache
<$> obj
.: "status"
<$> obj .: "status"

instance FromJSON RevisionDependencyCacheStatus where
parseJSON = withText "RevisionDependencyCacheStatus" $ \txt -> case Text.toUpper txt of
Expand Down
3 changes: 1 addition & 2 deletions src/Strategy/Conda/CondaEnvCreate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ data CondaEnvDep = CondaEnvDep
instance FromJSON CondaEnvCreateOut where
parseJSON = withObject "CondaEnvOutput" $ \obj ->
CondaEnvCreateOut
<$> obj
.: "dependencies"
<$> obj .: "dependencies"

type Parser = Parsec Void Text

Expand Down

0 comments on commit ab05c1e

Please sign in to comment.