Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to fourmolu 0.17.0.0 #823

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# editorconfig
30db58ead8d80749c1ff86bacc3ef89899dae62f
# fourmolu 0.17.0.0
484dec2c7a8a335e26754f3d331f734b5224c640
2 changes: 1 addition & 1 deletion .github/workflows/linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: haskell-actions/run-fourmolu@v11
with:
version: "0.14.1.0"
version: "0.17.0.0"
pattern: |
src/**/*.hs
test/**/*.hs
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The compiler version used is described in the `cabal.project` file.
The following Haskell command-line tools will have to be installed:

* `postgresql-migration`: To perform schema migrations
* `fourmolu`: To style the code base. Version is 0.14.1.0
* `fourmolu`: To style the code base. Version is 0.17.0.0
* `hlint` & `apply-refact`: To enforce certain patterns in the code base ("lint")
* `cabal-fmt` and `nixfmt`: To style the cabal and nix files
* `ghcid`: To automatically reload the Haskell code base upon source changes
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ARG UID=1000

ARG GHC_VERSION=9.6.6
ARG CABAL_VERSION=3.10.3.0
ARG FOURMOLU_VERSION=0.14.1.0
ARG FOURMOLU_VERSION=0.17.0.0
ARG HLINT_VERSION=3.8
ARG APPLY_REFACT_VERSION=0.14.0.0
ARG CABAL_FMT_VERSION=0.1.12
Expand All @@ -27,7 +27,7 @@ RUN chown $USER:$USER /flora-server

RUN mkdir /home/$USER/.cabal
RUN chown -R $USER:$USER /home/$USER/.cabal
WORKDIR /flora-server
WORKDIR /flora-server

RUN apt update && \
apt install -y build-essential curl libffi-dev libffi8 libgmp-dev libgmp10 libncurses-dev libncurses5 libtinfo5 git libsodium-dev pkg-config
Expand All @@ -39,7 +39,7 @@ ENV BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK="YES"
ENV PATH="$PATH:/home/$USER/.ghcup/bin"
RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN curl -fsSL https://deb.nodesource.com/setup_18.x | bash -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list
RUN apt install -y nodejs libpq-dev mcpp wget zsh tmux postgresql-client
RUN corepack enable
USER ${USER}
Expand Down
2 changes: 1 addition & 1 deletion app/cli/DesignSystem.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import Data.Time.Clock (UTCTime (..))
import Data.UUID qualified as UUID
import Data.Vector (Vector)
import Data.Vector qualified as Vector
import Distribution.SPDX
import Distribution.Version
import Effectful
import Effectful.Fail
Expand All @@ -26,7 +27,6 @@ import Security.Advisories.Core.HsecId qualified as HsecId
import Security.CVSS

import Advisories.Model.Affected.Types
import Distribution.SPDX
import Flora.Environment.Config
import Flora.Model.Category
import Flora.Model.Category qualified as Category
Expand Down
64 changes: 32 additions & 32 deletions app/cli/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ import Data.Set (Set)
import Data.Text (Text)
import Data.Text qualified as Text
import Data.Text.Display (display)
import DesignSystem (generateComponents)
import Distribution.Version (Version)
import Effectful
import Effectful.Error.Static (Error, runErrorNoCallStack)
import Effectful.Fail
import Effectful.FileSystem
import Effectful.Log (Log, runLog)
import Effectful.Poolboy
import Effectful.PostgreSQL.Transact.Effect
import Effectful.Reader.Static (Reader)
import Effectful.Reader.Static qualified as Reader
Expand All @@ -35,10 +33,13 @@ import Monitor.Tracing.Zipkin (Zipkin (..))
import Optics.Core
import Options.Applicative
import Sel.Hashing.Password qualified as Sel
import System.Exit (exitFailure)
import System.FilePath ((</>))

import Advisories.Import (importAdvisories)
import Advisories.Import.Error (AdvisoryImportError)
import DesignSystem (generateComponents)
import Effectful.Poolboy
import Flora.Environment (getFloraEnv)
import Flora.Environment.Env
import Flora.Import.Categories (importCategories)
Expand All @@ -53,12 +54,11 @@ import Flora.Model.User
import Flora.Model.User.Query qualified as Query
import Flora.Model.User.Update
import Flora.Tracing qualified as Tracing
import System.Exit (exitFailure)

data Options = Options
{ cliCommand :: Command
}
deriving stock (Show, Eq)
deriving stock (Eq, Show)

data Command
= Provision ProvisionTarget
Expand All @@ -68,13 +68,13 @@ data Command
| ImportIndex FilePath Text
| ProvisionRepository Text Text Text
| ImportPackageTarball PackageName Version FilePath
deriving stock (Show, Eq)
deriving stock (Eq, Show)

data ProvisionTarget
= Categories
| TestPackages Text
| Advisories
deriving stock (Show, Eq)
deriving stock (Eq, Show)

data UserCreationOptions = UserCreationOptions
{ username :: Text
Expand All @@ -83,7 +83,7 @@ data UserCreationOptions = UserCreationOptions
, isAdmin :: Bool
, canLogin :: Bool
}
deriving stock (Generic, Show, Eq)
deriving stock (Eq, Generic, Show)

main :: IO ()
main = Log.withStdOutLogger $ \logger -> do
Expand Down Expand Up @@ -190,20 +190,20 @@ parseImportPackageTarball =
<*> argument str (metavar "PATH")

runOptions
:: ( Log :> es
, FileSystem :> es
:: ( BlobStoreAPI :> es
, DB :> es
, Time :> es
, Fail :> es
, IOE :> es
, BlobStoreAPI :> es
, State (Set (Namespace, PackageName, Version)) :> es
, Poolboy :> es
, Error (NonEmpty AdvisoryImportError) :> es
, Trace :> es
, Fail :> es
, FileSystem :> es
, HasField "metrics" r Metrics
, HasField "mltp" r MLTP
, IOE :> es
, Log :> es
, Poolboy :> es
, Reader r :> es
, State (Set (Namespace, PackageName, Version)) :> es
, Time :> es
, Trace :> es
)
=> Options
-> Eff es ()
Expand Down Expand Up @@ -246,16 +246,16 @@ provisionRepository :: (DB :> es, IOE :> es) => Text -> Text -> Text -> Eff es (
provisionRepository name url description = Update.upsertPackageIndex name url description Nothing

importFolderOfCabalFiles
:: ( FileSystem :> es
, Time :> es
, Log :> es
, Poolboy :> es
, DB :> es
, IOE :> es
, State (Set (Namespace, PackageName, Version)) :> es
:: ( DB :> es
, FileSystem :> es
, HasField "metrics" r Metrics
, HasField "mltp" r MLTP
, IOE :> es
, Log :> es
, Poolboy :> es
, Reader r :> es
, State (Set (Namespace, PackageName, Version)) :> es
, Time :> es
)
=> FilePath
-> Text
Expand All @@ -269,15 +269,15 @@ importFolderOfCabalFiles path repository = do
importAllFilesInRelativeDirectory (user ^. #userId) (repository, packageIndex.url) (path </> Text.unpack repository)

importIndex
:: ( Time :> es
, Log :> es
, Poolboy :> es
, DB :> es
, IOE :> es
, State (Set (Namespace, PackageName, Version)) :> es
:: ( DB :> es
, HasField "metrics" r Metrics
, HasField "mltp" r MLTP
, IOE :> es
, Log :> es
, Poolboy :> es
, Reader r :> es
, State (Set (Namespace, PackageName, Version)) :> es
, Time :> es
)
=> FilePath
-> Text
Expand All @@ -291,10 +291,10 @@ importIndex path repository = do
importFromIndex (user ^. #userId) repository path

importPackageTarball
:: ( Log :> es
, BlobStoreAPI :> es
, IOE :> es
:: ( BlobStoreAPI :> es
, DB :> es
, IOE :> es
, Log :> es
)
=> PackageName
-> Version
Expand Down
2 changes: 1 addition & 1 deletion app/server/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ main = do
checkIfIndexRefreshJobIsPlanned env.pool
runFlora

checkRepositoriesAreConfigured :: (DB :> es, Log :> es, IOE :> es) => Eff es ()
checkRepositoriesAreConfigured :: (DB :> es, IOE :> es, Log :> es) => Eff es ()
checkRepositoriesAreConfigured = do
let expectedRepositories = Set.fromList ["hackage", "cardano", "horizon"]
(result :: (Vector (Only Text))) <-
Expand Down
2 changes: 2 additions & 0 deletions changelog.d/823
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
synopsis: Upgrade to Fourmolu 0.17.0.0
prs: #823
4 changes: 4 additions & 0 deletions fourmolu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ newlines-between-decls: 1 # number of newlines between top-level declarations
fixities: []
function-arrows: leading
single-constraint-parens: never
import-grouping: by-scope
sort-constraints: true
sort-derived-classes: true
sort-deriving-clauses: true
22 changes: 11 additions & 11 deletions src/advisories/Advisories/Import.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ import OSV.Reference.Orphans
-- | List deduplicated parsed Advisories
importAdvisories
:: ( DB :> es
, Trace :> es
, IOE :> es
, Error (NonEmpty AdvisoryImportError) :> es
, IOE :> es
, Trace :> es
)
=> FilePath
-> Eff es ()
Expand All @@ -49,9 +49,9 @@ importAdvisories root = Tracing.rootSpan alwaysSampled "import-advisories" $ do

importAdvisory
:: ( DB :> es
, Trace :> es
, IOE :> es
, Error (NonEmpty AdvisoryImportError) :> es
, IOE :> es
, Trace :> es
)
=> Advisory
-> Eff es ()
Expand Down Expand Up @@ -85,10 +85,10 @@ processAdvisory advisoryId advisory =
}

processAffectedPackages
:: ( IOE :> es
, DB :> es
, Trace :> es
:: ( DB :> es
, Error (NonEmpty AdvisoryImportError) :> es
, IOE :> es
, Trace :> es
)
=> AdvisoryId
-> Vector Affected
Expand All @@ -97,9 +97,9 @@ processAffectedPackages advisoryId affectedPackages = do
forM_ affectedPackages (processAffectedPackage advisoryId)

processAffectedPackage
:: ( IOE :> es
, DB :> es
:: ( DB :> es
, Error (NonEmpty AdvisoryImportError) :> es
, IOE :> es
, Trace :> es
)
=> AdvisoryId
Expand Down Expand Up @@ -132,8 +132,8 @@ processAffectedPackage advisoryId affected = do
processAffectedVersionRanges affectedPackageId affected.affectedVersions

processAffectedVersionRanges
:: ( IOE :> es
, DB :> es
:: ( DB :> es
, IOE :> es
)
=> AffectedPackageId
-> [AffectedVersionRange]
Expand Down
2 changes: 1 addition & 1 deletion src/advisories/Advisories/Import/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ data AdvisoryImportError
= AffectedPackageNotFound Namespace PackageName
| AdvisoryParsingError (FilePath, ParseAdvisoryError)
| AffectedVersionNotFound Namespace PackageName Version
deriving stock (Eq, Show, Generic)
deriving stock (Eq, Generic, Show)
6 changes: 3 additions & 3 deletions src/advisories/Advisories/Model/Advisory/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Pandoc.Orphans ()

newtype AdvisoryId = AdvisoryId {getAdvisoryId :: UUID}
deriving stock (Generic, Show)
deriving newtype (Eq, Ord, FromJSON, ToJSON, FromField, ToField, NFData)
deriving newtype (Eq, FromField, FromJSON, NFData, Ord, ToField, ToJSON)

data AdvisoryDAO = AdvisoryDAO
{ advisoryId :: AdvisoryId
Expand All @@ -42,8 +42,8 @@ data AdvisoryDAO = AdvisoryDAO
, summary :: Text
, details :: Text
}
deriving stock (Show, Generic)
deriving anyclass (FromRow, ToRow, NFData)
deriving stock (Generic, Show)
deriving anyclass (FromRow, NFData, ToRow)
deriving
(Entity)
via (GenericEntity '[TableName "security_advisories"] AdvisoryDAO)
18 changes: 9 additions & 9 deletions src/advisories/Advisories/Model/Affected/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Flora.Model.Package.Types
newtype AffectedPackageId = AffectedPackageId {getAffectedPackageId :: UUID}
deriving stock (Generic, Show)
deriving
(Eq, Ord, FromJSON, ToJSON, FromField, ToField, NFData)
(Eq, FromField, FromJSON, NFData, Ord, ToField, ToJSON)
via UUID

data AffectedPackageDAO = AffectedPackageDAO
Expand All @@ -41,8 +41,8 @@ data AffectedPackageDAO = AffectedPackageDAO
, operatingSystems :: Maybe (Vector OS)
, declarations :: Vector AffectedDeclaration
}
deriving stock (Show, Generic)
deriving anyclass (FromRow, ToRow, NFData)
deriving stock (Generic, Show)
deriving anyclass (FromRow, NFData, ToRow)
deriving
(Entity)
via (GenericEntity '[TableName "affected_packages"] AffectedPackageDAO)
Expand All @@ -51,8 +51,8 @@ data AffectedDeclaration = AffectedDeclaration
{ canonicalPath :: Text
, affectedRange :: VersionRange
}
deriving stock (Show, Generic)
deriving anyclass (NFData, ToJSON, FromJSON)
deriving stock (Generic, Show)
deriving anyclass (FromJSON, NFData, ToJSON)

deriving via (Aeson AffectedDeclaration) instance ToField AffectedDeclaration

Expand All @@ -61,7 +61,7 @@ deriving via (Aeson AffectedDeclaration) instance FromField AffectedDeclaration
newtype AffectedVersionId = AffectedVersionId {getAffectedVersionId :: UUID}
deriving stock (Generic, Show)
deriving
(Eq, Ord, FromJSON, ToJSON, FromField, ToField, NFData)
(Eq, FromField, FromJSON, NFData, Ord, ToField, ToJSON)
via UUID

data AffectedVersionRangeDAO = AffectedVersionRangeDAO
Expand All @@ -70,8 +70,8 @@ data AffectedVersionRangeDAO = AffectedVersionRangeDAO
, introducedVersion :: Version
, fixedVersion :: Maybe Version
}
deriving stock (Show, Generic)
deriving anyclass (FromRow, ToRow, NFData)
deriving stock (Generic, Show)
deriving anyclass (FromRow, NFData, ToRow)
deriving
(Entity)
via (GenericEntity '[TableName "affected_version_ranges"] AffectedVersionRangeDAO)
Expand All @@ -85,5 +85,5 @@ data PackageAdvisoryPreview = PackageAdvisoryPreview
, published :: UTCTime
, cvss :: CVSS
}
deriving stock (Show, Generic)
deriving stock (Generic, Show)
deriving anyclass (FromRow, NFData)
Loading