{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
module Distribution.PackageDescription.Check
(
CheckExplanation (..)
, CheckExplanationID
, CheckExplanationIDString
, PackageCheck (..)
, checkPackage
, checkConfiguredPackage
, wrapParseWarning
, ppPackageCheck
, ppCheckExplanationId
, isHackageDistError
, filterPackageChecksById
, filterPackageChecksByIdString
, checkPackageFiles
, checkPackageFilesGPD
, checkPackageContent
, CheckPackageContentOps (..)
) where
import Distribution.Compat.Prelude
import Prelude ()
import Data.List (group)
import Distribution.CabalSpecVersion
import Distribution.Compat.Lens
import Distribution.Compiler
import Distribution.License
import Distribution.Package
import Distribution.PackageDescription
import Distribution.PackageDescription.Check.Common
import Distribution.PackageDescription.Check.Conditional
import Distribution.PackageDescription.Check.Monad
import Distribution.PackageDescription.Check.Paths
import Distribution.PackageDescription.Check.Target
import Distribution.PackageDescription.Check.Warning
import Distribution.Parsec.Warning (PWarning)
import Distribution.Pretty (prettyShow)
import Distribution.Simple.Glob
( Glob
, GlobResult (..)
, globMatches
, parseFileGlob
, runDirFileGlob
)
import Distribution.Simple.Utils hiding (findPackageDesc, notice)
import Distribution.Utils.Generic (isAscii)
import Distribution.Utils.Path
import Distribution.Verbosity
import Distribution.Version
import System.FilePath (splitExtension, takeFileName)
import qualified Data.ByteString.Lazy as BS
import qualified Distribution.SPDX as SPDX
import qualified System.Directory as System
import qualified System.Directory (getDirectoryContents)
import qualified System.FilePath.Windows as FilePath.Windows (isValid)
import qualified Data.Set as Set
import qualified Distribution.Utils.ShortText as ShortText
import qualified Distribution.Types.GenericPackageDescription.Lens as L
import Control.Monad
checkPackagePrim
:: Monad m
=> Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim :: forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
b Maybe (CheckPackageContentOps m)
mco Maybe (CheckPreDistributionOps m)
mpdo GenericPackageDescription
gpd = do
let cm :: CheckM m ()
cm = GenericPackageDescription -> CheckM m ()
forall (m :: * -> *).
Monad m =>
GenericPackageDescription -> CheckM m ()
checkGenericPackageDescription GenericPackageDescription
gpd
ci :: CheckInterface m
ci = Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> CheckInterface m
forall (m :: * -> *).
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> CheckInterface m
CheckInterface Bool
b Maybe (CheckPackageContentOps m)
mco Maybe (CheckPreDistributionOps m)
mpdo
ctx :: CheckCtx m
ctx = CheckInterface m -> GenericPackageDescription -> CheckCtx m
forall (m :: * -> *).
Monad m =>
CheckInterface m -> GenericPackageDescription -> CheckCtx m
pristineCheckCtx CheckInterface m
ci GenericPackageDescription
gpd
CheckM m () -> CheckCtx m -> m [PackageCheck]
forall (m :: * -> *).
Monad m =>
CheckM m () -> CheckCtx m -> m [PackageCheck]
execCheckM CheckM m ()
cm CheckCtx m
ctx
checkPackage :: GenericPackageDescription -> [PackageCheck]
checkPackage :: GenericPackageDescription -> [PackageCheck]
checkPackage GenericPackageDescription
gpd = Identity [PackageCheck] -> [PackageCheck]
forall a. Identity a -> a
runIdentity (Identity [PackageCheck] -> [PackageCheck])
-> Identity [PackageCheck] -> [PackageCheck]
forall a b. (a -> b) -> a -> b
$ Bool
-> Maybe (CheckPackageContentOps Identity)
-> Maybe (CheckPreDistributionOps Identity)
-> GenericPackageDescription
-> Identity [PackageCheck]
forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
True Maybe (CheckPackageContentOps Identity)
forall a. Maybe a
Nothing Maybe (CheckPreDistributionOps Identity)
forall a. Maybe a
Nothing GenericPackageDescription
gpd
checkConfiguredPackage :: PackageDescription -> [PackageCheck]
checkConfiguredPackage :: PackageDescription -> [PackageCheck]
checkConfiguredPackage PackageDescription
pd = GenericPackageDescription -> [PackageCheck]
checkPackage (PackageDescription -> GenericPackageDescription
pd2gpd PackageDescription
pd)
checkPackageContent
:: Monad m
=> CheckPackageContentOps m
-> GenericPackageDescription
-> m [PackageCheck]
checkPackageContent :: forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m
-> GenericPackageDescription -> m [PackageCheck]
checkPackageContent CheckPackageContentOps m
pops GenericPackageDescription
gpd = Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
False (CheckPackageContentOps m -> Maybe (CheckPackageContentOps m)
forall a. a -> Maybe a
Just CheckPackageContentOps m
pops) Maybe (CheckPreDistributionOps m)
forall a. Maybe a
Nothing GenericPackageDescription
gpd
checkPackageFilesGPD
:: Verbosity
-> GenericPackageDescription
-> FilePath
-> IO [PackageCheck]
checkPackageFilesGPD :: Verbosity
-> GenericPackageDescription -> String -> IO [PackageCheck]
checkPackageFilesGPD Verbosity
verbosity GenericPackageDescription
gpd String
root =
Bool
-> Maybe (CheckPackageContentOps IO)
-> Maybe (CheckPreDistributionOps IO)
-> GenericPackageDescription
-> IO [PackageCheck]
forall (m :: * -> *).
Monad m =>
Bool
-> Maybe (CheckPackageContentOps m)
-> Maybe (CheckPreDistributionOps m)
-> GenericPackageDescription
-> m [PackageCheck]
checkPackagePrim Bool
False (CheckPackageContentOps IO -> Maybe (CheckPackageContentOps IO)
forall a. a -> Maybe a
Just CheckPackageContentOps IO
checkFilesIO) (CheckPreDistributionOps IO -> Maybe (CheckPreDistributionOps IO)
forall a. a -> Maybe a
Just CheckPreDistributionOps IO
checkPreIO) GenericPackageDescription
gpd
where
checkFilesIO :: CheckPackageContentOps IO
checkFilesIO =
CheckPackageContentOps
{ doesFileExist :: String -> IO Bool
doesFileExist = String -> IO Bool
System.doesFileExist (String -> IO Bool) -> (String -> String) -> String -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
, doesDirectoryExist :: String -> IO Bool
doesDirectoryExist = String -> IO Bool
System.doesDirectoryExist (String -> IO Bool) -> (String -> String) -> String -> IO Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
, getDirectoryContents :: String -> IO [String]
getDirectoryContents = String -> IO [String]
System.Directory.getDirectoryContents (String -> IO [String])
-> (String -> String) -> String -> IO [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
, getFileContents :: String -> IO ByteString
getFileContents = String -> IO ByteString
BS.readFile (String -> IO ByteString)
-> (String -> String) -> String -> IO ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
}
checkPreIO :: CheckPreDistributionOps IO
checkPreIO =
CheckPreDistributionOps
{ runDirFileGlobM :: String -> Glob -> IO [GlobResult String]
runDirFileGlobM = \String
fp Glob
g -> Verbosity
-> Maybe CabalSpecVersion
-> String
-> Glob
-> IO [GlobResult String]
runDirFileGlob Verbosity
verbosity (CabalSpecVersion -> Maybe CabalSpecVersion
forall a. a -> Maybe a
Just (CabalSpecVersion -> Maybe CabalSpecVersion)
-> (PackageDescription -> CabalSpecVersion)
-> PackageDescription
-> Maybe CabalSpecVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageDescription -> CabalSpecVersion
specVersion (PackageDescription -> Maybe CabalSpecVersion)
-> PackageDescription -> Maybe CabalSpecVersion
forall a b. (a -> b) -> a -> b
$ GenericPackageDescription -> PackageDescription
packageDescription GenericPackageDescription
gpd) (String
root String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
fp) Glob
g
, getDirectoryContentsM :: String -> IO [String]
getDirectoryContentsM = String -> IO [String]
System.Directory.getDirectoryContents (String -> IO [String])
-> (String -> String) -> String -> IO [String]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> String
relative
}
relative :: FilePath -> FilePath
relative :: String -> String
relative String
path = String
root String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
path
checkPackageFiles
:: Verbosity
-> PackageDescription
-> FilePath
-> IO [PackageCheck]
checkPackageFiles :: Verbosity -> PackageDescription -> String -> IO [PackageCheck]
checkPackageFiles Verbosity
verbosity PackageDescription
pd String
oot =
Verbosity
-> GenericPackageDescription -> String -> IO [PackageCheck]
checkPackageFilesGPD Verbosity
verbosity (PackageDescription -> GenericPackageDescription
pd2gpd PackageDescription
pd) String
oot
checkGenericPackageDescription
:: Monad m
=> GenericPackageDescription
-> CheckM m ()
checkGenericPackageDescription :: forall (m :: * -> *).
Monad m =>
GenericPackageDescription -> CheckM m ()
checkGenericPackageDescription
gpd :: GenericPackageDescription
gpd@( GenericPackageDescription
PackageDescription
packageDescription_
Maybe Version
_gpdScannedVersion_
[PackageFlag]
genPackageFlags_
Maybe (CondTree ConfVar [Dependency] Library)
condLibrary_
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
condForeignLibs_
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
condExecutables_
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
condTestSuites_
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
condBenchmarks_
) =
do
PackageDescription -> CheckM m ()
forall (m :: * -> *). Monad m => PackageDescription -> CheckM m ()
checkPackageDescription PackageDescription
packageDescription_
let condAllLibraries :: [CondTree ConfVar [Dependency] Library]
condAllLibraries =
Maybe (CondTree ConfVar [Dependency] Library)
-> [CondTree ConfVar [Dependency] Library]
forall a. Maybe a -> [a]
maybeToList Maybe (CondTree ConfVar [Dependency] Library)
condLibrary_
[CondTree ConfVar [Dependency] Library]
-> [CondTree ConfVar [Dependency] Library]
-> [CondTree ConfVar [Dependency] Library]
forall a. [a] -> [a] -> [a]
++ (((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CondTree ConfVar [Dependency] Library)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> [CondTree ConfVar [Dependency] Library]
forall a b. (a -> b) -> [a] -> [b]
map (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CondTree ConfVar [Dependency] Library
forall a b. (a, b) -> b
snd [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
and
[ [(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
condExecutables_
, [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
condTestSuites_
, [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
condBenchmarks_
, [CondTree ConfVar [Dependency] Library] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [CondTree ConfVar [Dependency] Library]
condAllLibraries
, [(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
condForeignLibs_
]
)
(CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoTarget)
([UnqualComponentName]
nsubs, [UnqualComponentName]
nexes, [UnqualComponentName]
ntests, [UnqualComponentName]
nbenchs) <-
(CheckCtx m
-> ([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName]))
-> CheckM
m
([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName])
forall (m :: * -> *) a. Monad m => (CheckCtx m -> a) -> CheckM m a
asksCM
( ( \PNames
n ->
( PNames -> [UnqualComponentName]
pnSubLibs PNames
n
, PNames -> [UnqualComponentName]
pnExecs PNames
n
, PNames -> [UnqualComponentName]
pnTests PNames
n
, PNames -> [UnqualComponentName]
pnBenchs PNames
n
)
)
(PNames
-> ([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName]))
-> (CheckCtx m -> PNames)
-> CheckCtx m
-> ([UnqualComponentName], [UnqualComponentName],
[UnqualComponentName], [UnqualComponentName])
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CheckCtx m -> PNames
forall (m :: * -> *). CheckCtx m -> PNames
ccNames
)
let names :: [UnqualComponentName]
names = [[UnqualComponentName]] -> [UnqualComponentName]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat [[UnqualComponentName]
nsubs, [UnqualComponentName]
nexes, [UnqualComponentName]
ntests, [UnqualComponentName]
nbenchs]
dupes :: [UnqualComponentName]
dupes = [UnqualComponentName] -> [UnqualComponentName]
forall a. Ord a => [a] -> [a]
dups [UnqualComponentName]
names
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Bool -> Bool
not (Bool -> Bool)
-> ([UnqualComponentName] -> Bool) -> [UnqualComponentName] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [UnqualComponentName] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([UnqualComponentName] -> Bool) -> [UnqualComponentName] -> Bool
forall a b. (a -> b) -> a -> b
$ [UnqualComponentName] -> [UnqualComponentName]
forall a. Ord a => [a] -> [a]
dups [UnqualComponentName]
names)
(CheckExplanation -> PackageCheck
PackageBuildImpossible (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ [UnqualComponentName] -> CheckExplanation
DuplicateSections [UnqualComponentName]
dupes)
PackageDescription -> CheckM m ()
forall (m :: * -> *). Monad m => PackageDescription -> CheckM m ()
checkPackageDescription PackageDescription
packageDescription_
(PackageFlag -> CheckM m ()) -> [PackageFlag] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ PackageFlag -> CheckM m ()
forall (m :: * -> *). Monad m => PackageFlag -> CheckM m ()
checkFlagName [PackageFlag]
genPackageFlags_
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
checkSpecVer
CabalSpecVersion
CabalSpecV2_0
(Bool -> Bool
not (Bool -> Bool)
-> ([(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Bool)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Bool)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Bool
forall a b. (a -> b) -> a -> b
$ [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
CVMultiLib)
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
checkSpecVer
CabalSpecVersion
CabalSpecV1_8
(Bool -> Bool
not (Bool -> Bool)
-> ([(UnqualComponentName,
CondTree ConfVar [Dependency] TestSuite)]
-> Bool)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Bool)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Bool
forall a b. (a -> b) -> a -> b
$ [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
condTestSuites_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
CVTestSuite)
UnqualComponentName
pName <-
(CheckCtx m -> UnqualComponentName) -> CheckM m UnqualComponentName
forall (m :: * -> *) a. Monad m => (CheckCtx m -> a) -> CheckM m a
asksCM
( PackageName -> UnqualComponentName
packageNameToUnqualComponentName
(PackageName -> UnqualComponentName)
-> (CheckCtx m -> PackageName) -> CheckCtx m -> UnqualComponentName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageIdentifier -> PackageName
pkgName
(PackageIdentifier -> PackageName)
-> (CheckCtx m -> PackageIdentifier) -> CheckCtx m -> PackageName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PNames -> PackageIdentifier
pnPackageId
(PNames -> PackageIdentifier)
-> (CheckCtx m -> PNames) -> CheckCtx m -> PackageIdentifier
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CheckCtx m -> PNames
forall (m :: * -> *). CheckCtx m -> PNames
ccNames
)
let ads :: [AssocDep]
ads =
[AssocDep]
-> (CondTree ConfVar [Dependency] Library -> [AssocDep])
-> Maybe (CondTree ConfVar [Dependency] Library)
-> [AssocDep]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] ((AssocDep -> [AssocDep] -> [AssocDep]
forall a. a -> [a] -> [a]
: []) (AssocDep -> [AssocDep])
-> (CondTree ConfVar [Dependency] Library -> AssocDep)
-> CondTree ConfVar [Dependency] Library
-> [AssocDep]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. UnqualComponentName
-> CondTree ConfVar [Dependency] Library -> AssocDep
extractAssocDeps UnqualComponentName
pName) Maybe (CondTree ConfVar [Dependency] Library)
condLibrary_
[AssocDep] -> [AssocDep] -> [AssocDep]
forall a. [a] -> [a] -> [a]
++ ((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> AssocDep)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> [AssocDep]
forall a b. (a -> b) -> [a] -> [b]
map ((UnqualComponentName
-> CondTree ConfVar [Dependency] Library -> AssocDep)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> AssocDep
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry UnqualComponentName
-> CondTree ConfVar [Dependency] Library -> AssocDep
extractAssocDeps) [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_
case Maybe (CondTree ConfVar [Dependency] Library)
condLibrary_ of
Just CondTree ConfVar [Dependency] Library
cl ->
[PackageFlag]
-> (Library -> CheckM m ())
-> (UnqualComponentName -> Library -> Library)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CheckM m ()
forall (m :: * -> *) a.
(Monad m, Eq a, Monoid a) =>
[PackageFlag]
-> (a -> CheckM m ())
-> (UnqualComponentName -> a -> a)
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
-> CheckM m ()
checkCondTarget
[PackageFlag]
genPackageFlags_
(Bool -> [AssocDep] -> Library -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> [AssocDep] -> Library -> CheckM m ()
checkLibrary Bool
False [AssocDep]
ads)
((Library -> Library) -> UnqualComponentName -> Library -> Library
forall a b. a -> b -> a
const Library -> Library
forall a. a -> a
id)
(UnqualComponentName
forall a. Monoid a => a
mempty, CondTree ConfVar [Dependency] Library
cl)
Maybe (CondTree ConfVar [Dependency] Library)
Nothing -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CheckM m ())
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
( [PackageFlag]
-> (Library -> CheckM m ())
-> (UnqualComponentName -> Library -> Library)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> CheckM m ()
forall (m :: * -> *) a.
(Monad m, Eq a, Monoid a) =>
[PackageFlag]
-> (a -> CheckM m ())
-> (UnqualComponentName -> a -> a)
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
-> CheckM m ()
checkCondTarget
[PackageFlag]
genPackageFlags_
(Bool -> [AssocDep] -> Library -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> [AssocDep] -> Library -> CheckM m ()
checkLibrary Bool
False [AssocDep]
ads)
(\UnqualComponentName
u Library
l -> Library
l{libName = maybeToLibraryName (Just u)})
)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
condSubLibraries_
((UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> CheckM m ())
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
( [PackageFlag]
-> (ForeignLib -> CheckM m ())
-> (UnqualComponentName -> ForeignLib -> ForeignLib)
-> (UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> CheckM m ()
forall (m :: * -> *) a.
(Monad m, Eq a, Monoid a) =>
[PackageFlag]
-> (a -> CheckM m ())
-> (UnqualComponentName -> a -> a)
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
-> CheckM m ()
checkCondTarget
[PackageFlag]
genPackageFlags_
ForeignLib -> CheckM m ()
forall (m :: * -> *). Monad m => ForeignLib -> CheckM m ()
checkForeignLib
((ForeignLib -> ForeignLib)
-> UnqualComponentName -> ForeignLib -> ForeignLib
forall a b. a -> b -> a
const ForeignLib -> ForeignLib
forall a. a -> a
id)
)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
condForeignLibs_
((UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> CheckM m ())
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
( [PackageFlag]
-> (Executable -> CheckM m ())
-> (UnqualComponentName -> Executable -> Executable)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> CheckM m ()
forall (m :: * -> *) a.
(Monad m, Eq a, Monoid a) =>
[PackageFlag]
-> (a -> CheckM m ())
-> (UnqualComponentName -> a -> a)
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
-> CheckM m ()
checkCondTarget
[PackageFlag]
genPackageFlags_
([AssocDep] -> Executable -> CheckM m ()
forall (m :: * -> *).
Monad m =>
[AssocDep] -> Executable -> CheckM m ()
checkExecutable [AssocDep]
ads)
((Executable -> Executable)
-> UnqualComponentName -> Executable -> Executable
forall a b. a -> b -> a
const Executable -> Executable
forall a. a -> a
id)
)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
condExecutables_
((UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> CheckM m ())
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
( [PackageFlag]
-> (TestSuite -> CheckM m ())
-> (UnqualComponentName -> TestSuite -> TestSuite)
-> (UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> CheckM m ()
forall (m :: * -> *) a.
(Monad m, Eq a, Monoid a) =>
[PackageFlag]
-> (a -> CheckM m ())
-> (UnqualComponentName -> a -> a)
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
-> CheckM m ()
checkCondTarget
[PackageFlag]
genPackageFlags_
([AssocDep] -> TestSuite -> CheckM m ()
forall (m :: * -> *).
Monad m =>
[AssocDep] -> TestSuite -> CheckM m ()
checkTestSuite [AssocDep]
ads)
(\UnqualComponentName
u TestSuite
l -> TestSuite
l{testName = u})
)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
condTestSuites_
((UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> CheckM m ())
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_
( [PackageFlag]
-> (Benchmark -> CheckM m ())
-> (UnqualComponentName -> Benchmark -> Benchmark)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> CheckM m ()
forall (m :: * -> *) a.
(Monad m, Eq a, Monoid a) =>
[PackageFlag]
-> (a -> CheckM m ())
-> (UnqualComponentName -> a -> a)
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
-> CheckM m ()
checkCondTarget
[PackageFlag]
genPackageFlags_
([AssocDep] -> Benchmark -> CheckM m ()
forall (m :: * -> *).
Monad m =>
[AssocDep] -> Benchmark -> CheckM m ()
checkBenchmark [AssocDep]
ads)
(\UnqualComponentName
u Benchmark
l -> Benchmark
l{benchmarkName = u})
)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
condBenchmarks_
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Set FlagName
decFlags Set FlagName -> Set FlagName -> Bool
forall a. Eq a => a -> a -> Bool
/= Set FlagName
usedFlags)
(CheckExplanation -> PackageCheck
PackageDistSuspicious (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ Set FlagName -> Set FlagName -> CheckExplanation
DeclaredUsedFlags Set FlagName
decFlags Set FlagName
usedFlags)
(PackageCheck -> CheckM m ()) -> [PackageCheck] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP (GenericPackageDescription -> [PackageCheck]
checkDuplicateModules GenericPackageDescription
gpd)
where
checkFlagName :: Monad m => PackageFlag -> CheckM m ()
checkFlagName :: forall (m :: * -> *). Monad m => PackageFlag -> CheckM m ()
checkFlagName PackageFlag
pf =
let fn :: String
fn = FlagName -> String
unFlagName (FlagName -> String)
-> (PackageFlag -> FlagName) -> PackageFlag -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageFlag -> FlagName
flagName (PackageFlag -> String) -> PackageFlag -> String
forall a b. (a -> b) -> a -> b
$ PackageFlag
pf
invalidFlagName :: String -> Bool
invalidFlagName (Char
'-' : String
_) = Bool
True
invalidFlagName String
cs = (Char -> Bool) -> String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (Bool -> Bool
not (Bool -> Bool) -> (Char -> Bool) -> Char -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> Bool
isAscii) String
cs
in Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(String -> Bool
invalidFlagName String
fn)
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ [String] -> CheckExplanation
SuspiciousFlagName [String
fn])
decFlags :: Set.Set FlagName
decFlags :: Set FlagName
decFlags = Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[PackageFlag]
[PackageFlag]
Lens' GenericPackageDescription [PackageFlag]
L.genPackageFlags LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[PackageFlag]
[PackageFlag]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [PackageFlag] -> Const (Set FlagName) [PackageFlag])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (PackageFlag -> Const (Set FlagName) PackageFlag)
-> [PackageFlag] -> Const (Set FlagName) [PackageFlag]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((PackageFlag -> Const (Set FlagName) PackageFlag)
-> [PackageFlag] -> Const (Set FlagName) [PackageFlag])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> PackageFlag -> Const (Set FlagName) PackageFlag)
-> (FlagName -> Const (Set FlagName) FlagName)
-> [PackageFlag]
-> Const (Set FlagName) [PackageFlag]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> PackageFlag -> Const (Set FlagName) PackageFlag
Lens' PackageFlag FlagName
L.flagName) GenericPackageDescription
gpd
usedFlags :: Set.Set FlagName
usedFlags :: Set FlagName
usedFlags =
[Set FlagName] -> Set FlagName
forall a. Monoid a => [a] -> a
mconcat
[ Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
(Maybe (CondTree ConfVar [Dependency] Library))
(Maybe (CondTree ConfVar [Dependency] Library))
Lens'
GenericPackageDescription
(Maybe (CondTree ConfVar [Dependency] Library))
L.condLibrary LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
(Maybe (CondTree ConfVar [Dependency] Library))
(Maybe (CondTree ConfVar [Dependency] Library))
-> ((FlagName -> Const (Set FlagName) FlagName)
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library)))
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Maybe a -> f (Maybe b)
traverse ((CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library)))
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> (FlagName -> Const (Set FlagName) FlagName)
-> Maybe (CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName) (Maybe (CondTree ConfVar [Dependency] Library))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
L.condSubLibraries LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Library)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Library)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Library)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Library)
(CondTree ConfVar [Dependency] Library)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Library
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Library)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
L.condForeignLibs LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] ForeignLib)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] ForeignLib
-> Const (Set FlagName) (CondTree ConfVar [Dependency] ForeignLib))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] ForeignLib)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] ForeignLib)
(CondTree ConfVar [Dependency] ForeignLib)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] ForeignLib
-> Const (Set FlagName) (CondTree ConfVar [Dependency] ForeignLib)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
L.condExecutables LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable))
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName,
CondTree ConfVar [Dependency] Executable)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Executable)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Executable
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Executable))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Executable)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Executable)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Executable)
(CondTree ConfVar [Dependency] Executable)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Executable
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Executable)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
L.condTestSuites LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] TestSuite
-> Const (Set FlagName) (CondTree ConfVar [Dependency] TestSuite))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] TestSuite)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] TestSuite)
(CondTree ConfVar [Dependency] TestSuite)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] TestSuite
-> Const (Set FlagName) (CondTree ConfVar [Dependency] TestSuite)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
, Getting (Set FlagName) GenericPackageDescription FlagName
-> GenericPackageDescription -> Set FlagName
forall a s. Getting (Set a) s a -> s -> Set a
toSetOf (LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
Lens'
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
L.condBenchmarks LensLike
(Const (Set FlagName))
GenericPackageDescription
GenericPackageDescription
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> ((FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)])
-> Getting (Set FlagName) GenericPackageDescription FlagName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (((UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark))
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)])
-> ((FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark))
-> (FlagName -> Const (Set FlagName) FlagName)
-> [(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
-> Const
(Set FlagName)
[(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
forall c a b (f :: * -> *).
Functor f =>
LensLike f (c, a) (c, b) a b
_2 LensLike
(Const (Set FlagName))
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
-> ((FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Benchmark
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Benchmark))
-> (FlagName -> Const (Set FlagName) FlagName)
-> (UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
-> Const
(Set FlagName)
(UnqualComponentName, CondTree ConfVar [Dependency] Benchmark)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
ConfVar
ConfVar
forall v c a w (f :: * -> *).
Applicative f =>
LensLike f (CondTree v c a) (CondTree w c a) v w
traverseCondTreeV LensLike
(Const (Set FlagName))
(CondTree ConfVar [Dependency] Benchmark)
(CondTree ConfVar [Dependency] Benchmark)
ConfVar
ConfVar
-> ((FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar)
-> (FlagName -> Const (Set FlagName) FlagName)
-> CondTree ConfVar [Dependency] Benchmark
-> Const (Set FlagName) (CondTree ConfVar [Dependency] Benchmark)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (FlagName -> Const (Set FlagName) FlagName)
-> ConfVar -> Const (Set FlagName) ConfVar
Traversal' ConfVar FlagName
L._PackageFlag) GenericPackageDescription
gpd
]
checkPackageDescription :: Monad m => PackageDescription -> CheckM m ()
checkPackageDescription :: forall (m :: * -> *). Monad m => PackageDescription -> CheckM m ()
checkPackageDescription
pkg :: PackageDescription
pkg@( PackageDescription
CabalSpecVersion
specVersion_
PackageIdentifier
package_
Either License License
licenseRaw_
[RelativePath Pkg 'File]
licenseFiles_
ShortText
_copyright_
ShortText
maintainer_
ShortText
_author_
ShortText
_stability_
[(CompilerFlavor, VersionRange)]
testedWith_
ShortText
_homepage_
ShortText
_pkgUrl_
ShortText
_bugReports_
[SourceRepo]
sourceRepos_
ShortText
synopsis_
ShortText
description_
ShortText
category_
[(String, String)]
customFieldsPD_
Maybe BuildType
buildTypeRaw_
Maybe SetupBuildInfo
setupBuildInfo_
Maybe Library
_library_
[Library]
_subLibraries_
[Executable]
_executables_
[ForeignLib]
_foreignLibs_
[TestSuite]
_testSuites_
[Benchmark]
_benchmarks_
[RelativePath DataDir 'File]
dataFiles_
SymbolicPath Pkg ('Dir DataDir)
dataDir_
[RelativePath Pkg 'File]
extraSrcFiles_
[RelativePath Pkg 'File]
extraTmpFiles_
[RelativePath Pkg 'File]
extraDocFiles_
[RelativePath Pkg 'File]
extraFiles_
) = do
PackageIdentifier -> CheckM m ()
forall (m :: * -> *). Monad m => PackageIdentifier -> CheckM m ()
checkPackageId PackageIdentifier
package_
let pn :: PackageName
pn = PackageIdentifier -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageIdentifier
package_
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (String -> Bool) -> (PackageName -> String) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageName -> String
unPackageName (PackageName -> Bool) -> PackageName -> Bool
forall a b. (a -> b) -> a -> b
$ PackageName
pn)
(CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoNameField)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Version
nullVersion Version -> Version -> Bool
forall a. Eq a => a -> a -> Bool
== PackageIdentifier -> Version
forall pkg. Package pkg => pkg -> Version
packageVersion PackageIdentifier
package_)
(CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoVersionField)
[UnqualComponentName]
nsubs <- (CheckCtx m -> [UnqualComponentName])
-> CheckM m [UnqualComponentName]
forall (m :: * -> *) a. Monad m => (CheckCtx m -> a) -> CheckM m a
asksCM (PNames -> [UnqualComponentName]
pnSubLibs (PNames -> [UnqualComponentName])
-> (CheckCtx m -> PNames) -> CheckCtx m -> [UnqualComponentName]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CheckCtx m -> PNames
forall (m :: * -> *). CheckCtx m -> PNames
ccNames)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
((String -> Bool) -> [String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any (String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== PackageName -> String
forall a. Pretty a => a -> String
prettyShow PackageName
pn) (UnqualComponentName -> String
forall a. Pretty a => a -> String
prettyShow (UnqualComponentName -> String)
-> [UnqualComponentName] -> [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [UnqualComponentName]
nsubs))
(CheckExplanation -> PackageCheck
PackageBuildImpossible (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ PackageName -> CheckExplanation
IllegalLibraryName PackageName
pn)
ShortText -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
ShortText -> PackageCheck -> CheckM m ()
checkNull
ShortText
category_
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
MissingFieldCategory)
ShortText -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
ShortText -> PackageCheck -> CheckM m ()
checkNull
ShortText
maintainer_
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
MissingFieldMaintainer)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(ShortText -> Bool
ShortText.null ShortText
synopsis_ Bool -> Bool -> Bool
&& Bool -> Bool
not (ShortText -> Bool
ShortText.null ShortText
description_))
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
MissingFieldSynopsis)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(ShortText -> Bool
ShortText.null ShortText
description_ Bool -> Bool -> Bool
&& Bool -> Bool
not (ShortText -> Bool
ShortText.null ShortText
synopsis_))
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
MissingFieldDescription)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
((ShortText -> Bool) -> [ShortText] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ShortText -> Bool
ShortText.null [ShortText
synopsis_, ShortText
description_])
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingFieldSynOrDesc)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(ShortText -> Int
ShortText.length ShortText
synopsis_ Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
80)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
SynopsisTooLong)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( Bool -> Bool
not (ShortText -> Bool
ShortText.null ShortText
description_)
Bool -> Bool -> Bool
&& ShortText -> Int
ShortText.length ShortText
description_ Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= ShortText -> Int
ShortText.length ShortText
synopsis_
)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
ShortDesc)
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Bool -> String -> PathKind -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> String -> PathKind -> String -> CheckM m ()
checkPath Bool
False String
"extra-source-files" PathKind
PathKindGlob (String -> CheckM m ())
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraSrcFiles_
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Bool -> String -> PathKind -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> String -> PathKind -> String -> CheckM m ()
checkPath Bool
False String
"extra-tmp-files" PathKind
PathKindFile (String -> CheckM m ())
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraTmpFiles_
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Bool -> String -> PathKind -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> String -> PathKind -> String -> CheckM m ()
checkPath Bool
False String
"extra-doc-files" PathKind
PathKindGlob (String -> CheckM m ())
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraDocFiles_
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Bool -> String -> PathKind -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> String -> PathKind -> String -> CheckM m ()
checkPath Bool
False String
"extra-files" PathKind
PathKindGlob (String -> CheckM m ())
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraFiles_
(RelativePath DataDir 'File -> CheckM m ())
-> [RelativePath DataDir 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Bool -> String -> PathKind -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> String -> PathKind -> String -> CheckM m ()
checkPath Bool
False String
"data-files" PathKind
PathKindGlob (String -> CheckM m ())
-> (RelativePath DataDir 'File -> String)
-> RelativePath DataDir 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath DataDir 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath DataDir 'File]
dataFiles_
let rawDataDir :: String
rawDataDir = SymbolicPath Pkg ('Dir DataDir) -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath SymbolicPath Pkg ('Dir DataDir)
dataDir_
Bool -> String -> PathKind -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> String -> PathKind -> String -> CheckM m ()
checkPath Bool
True String
"data-dir" PathKind
PathKindDirectory String
rawDataDir
let licPaths :: [String]
licPaths = (RelativePath Pkg 'File -> String)
-> [RelativePath Pkg 'File] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath [RelativePath Pkg 'File]
licenseFiles_
(String -> CheckM m ()) -> [String] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (Bool -> String -> PathKind -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> String -> PathKind -> String -> CheckM m ()
checkPath Bool
False String
"license-file" PathKind
PathKindFile) [String]
licPaths
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ RelativePath Pkg 'File -> CheckM m ()
forall (m :: * -> *).
Monad m =>
RelativePath Pkg 'File -> CheckM m ()
checkLicFileExist [RelativePath Pkg 'File]
licenseFiles_
[Maybe Glob]
dataGlobs <- (RelativePath DataDir 'File -> CheckM m (Maybe Glob))
-> [RelativePath DataDir 'File] -> CheckM m [Maybe Glob]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (String -> String -> CheckM m (Maybe Glob)
forall (m :: * -> *).
Monad m =>
String -> String -> CheckM m (Maybe Glob)
checkGlob String
"data-files" (String -> CheckM m (Maybe Glob))
-> (RelativePath DataDir 'File -> String)
-> RelativePath DataDir 'File
-> CheckM m (Maybe Glob)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath DataDir 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath DataDir 'File]
dataFiles_
[Maybe Glob]
extraSrcGlobs <- (RelativePath Pkg 'File -> CheckM m (Maybe Glob))
-> [RelativePath Pkg 'File] -> CheckM m [Maybe Glob]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (String -> String -> CheckM m (Maybe Glob)
forall (m :: * -> *).
Monad m =>
String -> String -> CheckM m (Maybe Glob)
checkGlob String
"extra-source-files" (String -> CheckM m (Maybe Glob))
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m (Maybe Glob)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraSrcFiles_
[Maybe Glob]
docGlobs <- (RelativePath Pkg 'File -> CheckM m (Maybe Glob))
-> [RelativePath Pkg 'File] -> CheckM m [Maybe Glob]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (String -> String -> CheckM m (Maybe Glob)
forall (m :: * -> *).
Monad m =>
String -> String -> CheckM m (Maybe Glob)
checkGlob String
"extra-doc-files" (String -> CheckM m (Maybe Glob))
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m (Maybe Glob)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraDocFiles_
[Maybe Glob]
extraGlobs <- (RelativePath Pkg 'File -> CheckM m (Maybe Glob))
-> [RelativePath Pkg 'File] -> CheckM m [Maybe Glob]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (String -> String -> CheckM m (Maybe Glob)
forall (m :: * -> *).
Monad m =>
String -> String -> CheckM m (Maybe Glob)
checkGlob String
"extra-files" (String -> CheckM m (Maybe Glob))
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m (Maybe Glob)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraFiles_
[Glob] -> [Glob] -> [Glob] -> [Glob] -> CheckM m ()
forall (m :: * -> *).
Monad m =>
[Glob] -> [Glob] -> [Glob] -> [Glob] -> CheckM m ()
checkMissingDocs
([Maybe Glob] -> [Glob]
forall a. [Maybe a] -> [a]
catMaybes [Maybe Glob]
dataGlobs)
([Maybe Glob] -> [Glob]
forall a. [Maybe a] -> [a]
catMaybes [Maybe Glob]
extraSrcGlobs)
([Maybe Glob] -> [Glob]
forall a. [Maybe a] -> [a]
catMaybes [Maybe Glob]
docGlobs)
([Maybe Glob] -> [Glob]
forall a. [Maybe a] -> [a]
catMaybes [Maybe Glob]
extraGlobs)
Maybe SetupBuildInfo -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Maybe SetupBuildInfo -> CheckM m ()
checkSetupBuildInfo Maybe SetupBuildInfo
setupBuildInfo_
((CompilerFlavor, VersionRange) -> CheckM m ())
-> [(CompilerFlavor, VersionRange)] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (CompilerFlavor, VersionRange) -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CompilerFlavor, VersionRange) -> CheckM m ()
checkTestedWith [(CompilerFlavor, VersionRange)]
testedWith_
(License -> CheckM m ())
-> (License -> CheckM m ())
-> Either License License
-> CheckM m ()
forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either
License -> CheckM m ()
forall (m :: * -> *). Monad m => License -> CheckM m ()
checkNewLicense
(Bool -> License -> CheckM m ()
forall (m :: * -> *). Monad m => Bool -> License -> CheckM m ()
checkOldLicense (Bool -> License -> CheckM m ()) -> Bool -> License -> CheckM m ()
forall a b. (a -> b) -> a -> b
$ [RelativePath Pkg 'File] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [RelativePath Pkg 'File]
licenseFiles_)
Either License License
licenseRaw_
[SourceRepo] -> CheckM m ()
forall (m :: * -> *). Monad m => [SourceRepo] -> CheckM m ()
checkSourceRepos [SourceRepo]
sourceRepos_
((String, String) -> CheckM m ())
-> [(String, String)] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (String, String) -> CheckM m ()
forall (m :: * -> *). Monad m => (String, String) -> CheckM m ()
checkCustomField [(String, String)]
customFieldsPD_
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
checkSpecVer
CabalSpecVersion
CabalSpecV1_18
(Bool -> Bool
not (Bool -> Bool)
-> ([RelativePath Pkg 'File] -> Bool)
-> [RelativePath Pkg 'File]
-> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [RelativePath Pkg 'File] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([RelativePath Pkg 'File] -> Bool)
-> [RelativePath Pkg 'File] -> Bool
forall a b. (a -> b) -> a -> b
$ [RelativePath Pkg 'File]
extraDocFiles_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
CVExtraDocFiles)
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
checkSpecVer
CabalSpecVersion
CabalSpecV1_6
(Bool -> Bool
not (Bool -> Bool) -> ([SourceRepo] -> Bool) -> [SourceRepo] -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [SourceRepo] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null ([SourceRepo] -> Bool) -> [SourceRepo] -> Bool
forall a b. (a -> b) -> a -> b
$ [SourceRepo]
sourceRepos_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
CVSourceRepository)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( CabalSpecVersion
specVersion_ CabalSpecVersion -> CabalSpecVersion -> Bool
forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV1_24
Bool -> Bool -> Bool
&& Maybe SetupBuildInfo -> Bool
forall a. Maybe a -> Bool
isNothing Maybe SetupBuildInfo
setupBuildInfo_
Bool -> Bool -> Bool
&& Maybe BuildType
buildTypeRaw_ Maybe BuildType -> Maybe BuildType -> Bool
forall a. Eq a => a -> a -> Bool
== BuildType -> Maybe BuildType
forall a. a -> Maybe a
Just BuildType
Custom
)
(CheckExplanation -> PackageCheck
PackageBuildWarning CheckExplanation
CVCustomSetup)
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
checkSpecVer
CabalSpecVersion
CabalSpecV1_24
( Maybe SetupBuildInfo -> Bool
forall a. Maybe a -> Bool
isNothing Maybe SetupBuildInfo
setupBuildInfo_
Bool -> Bool -> Bool
&& Maybe BuildType
buildTypeRaw_ Maybe BuildType -> Maybe BuildType -> Bool
forall a. Eq a => a -> a -> Bool
== BuildType -> Maybe BuildType
forall a. a -> Maybe a
Just BuildType
Custom
)
(CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn CheckExplanation
CVExpliticDepsCustomSetup)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Maybe BuildType -> Bool
forall a. Maybe a -> Bool
isNothing Maybe BuildType
buildTypeRaw_ Bool -> Bool -> Bool
&& CabalSpecVersion
specVersion_ CabalSpecVersion -> CabalSpecVersion -> Bool
forall a. Ord a => a -> a -> Bool
< CabalSpecVersion
CabalSpecV2_2)
(CheckExplanation -> PackageCheck
PackageBuildWarning CheckExplanation
NoBuildType)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Maybe SetupBuildInfo -> Bool
forall a. Maybe a -> Bool
isJust Maybe SetupBuildInfo
setupBuildInfo_ Bool -> Bool -> Bool
&& PackageDescription -> BuildType
buildType PackageDescription
pkg BuildType -> [BuildType] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [BuildType
Custom, BuildType
Hooks])
(CheckExplanation -> PackageCheck
PackageBuildWarning CheckExplanation
NoCustomSetup)
BuildType -> CheckM m ()
forall (m :: * -> *). Monad m => BuildType -> CheckM m ()
checkConfigureExists (PackageDescription -> BuildType
buildType PackageDescription
pkg)
BuildType -> CheckM m ()
forall (m :: * -> *). Monad m => BuildType -> CheckM m ()
checkSetupExists (PackageDescription -> BuildType
buildType PackageDescription
pkg)
PackageName -> CheckM m ()
forall (m :: * -> *). Monad m => PackageName -> CheckM m ()
checkCabalFile (PackageDescription -> PackageName
forall pkg. Package pkg => pkg -> PackageName
packageName PackageDescription
pkg)
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (CabalSpecVersion -> String -> String -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> String -> String -> String -> CheckM m ()
checkGlobFile CabalSpecVersion
specVersion_ String
"." String
"extra-source-files" (String -> CheckM m ())
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraSrcFiles_
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (CabalSpecVersion -> String -> String -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> String -> String -> String -> CheckM m ()
checkGlobFile CabalSpecVersion
specVersion_ String
"." String
"extra-doc-files" (String -> CheckM m ())
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraDocFiles_
(RelativePath Pkg 'File -> CheckM m ())
-> [RelativePath Pkg 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (CabalSpecVersion -> String -> String -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> String -> String -> String -> CheckM m ()
checkGlobFile CabalSpecVersion
specVersion_ String
"." String
"extra-files" (String -> CheckM m ())
-> (RelativePath Pkg 'File -> String)
-> RelativePath Pkg 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath Pkg 'File]
extraFiles_
(RelativePath DataDir 'File -> CheckM m ())
-> [RelativePath DataDir 'File] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ (CabalSpecVersion -> String -> String -> String -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> String -> String -> String -> CheckM m ()
checkGlobFile CabalSpecVersion
specVersion_ String
rawDataDir String
"data-files" (String -> CheckM m ())
-> (RelativePath DataDir 'File -> String)
-> RelativePath DataDir 'File
-> CheckM m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RelativePath DataDir 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath) [RelativePath DataDir 'File]
dataFiles_
where
checkNull
:: Monad m
=> ShortText.ShortText
-> PackageCheck
-> CheckM m ()
checkNull :: forall (m :: * -> *).
Monad m =>
ShortText -> PackageCheck -> CheckM m ()
checkNull ShortText
st PackageCheck
c = Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP (ShortText -> Bool
ShortText.null ShortText
st) PackageCheck
c
checkTestedWith
:: Monad m
=> (CompilerFlavor, VersionRange)
-> CheckM m ()
checkTestedWith :: forall (m :: * -> *).
Monad m =>
(CompilerFlavor, VersionRange) -> CheckM m ()
checkTestedWith (OtherCompiler String
n, VersionRange
_) =
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP (CheckExplanation -> PackageCheck
PackageBuildWarning (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ [String] -> CheckExplanation
UnknownCompilers [String
n])
checkTestedWith (CompilerFlavor
compiler, VersionRange
versionRange) =
CompilerFlavor -> VersionRange -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CompilerFlavor -> VersionRange -> CheckM m ()
checkVersionRange CompilerFlavor
compiler VersionRange
versionRange
checkVersionRange
:: Monad m
=> CompilerFlavor
-> VersionRange
-> CheckM m ()
checkVersionRange :: forall (m :: * -> *).
Monad m =>
CompilerFlavor -> VersionRange -> CheckM m ()
checkVersionRange CompilerFlavor
cmp VersionRange
vr =
Bool -> CheckM m () -> CheckM m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when
(VersionRange -> Bool
isNoVersion VersionRange
vr)
( let dep :: [Dependency]
dep =
[ PackageName
-> VersionRange -> NonEmptySet LibraryName -> Dependency
Dependency
(String -> PackageName
mkPackageName (CompilerFlavor -> String
forall a. Pretty a => a -> String
prettyShow CompilerFlavor
cmp))
VersionRange
vr
NonEmptySet LibraryName
mainLibSet
]
in PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP (CheckExplanation -> PackageCheck
PackageDistInexcusable ([Dependency] -> CheckExplanation
InvalidTestWith [Dependency]
dep))
)
checkSetupBuildInfo :: Monad m => Maybe SetupBuildInfo -> CheckM m ()
checkSetupBuildInfo :: forall (m :: * -> *).
Monad m =>
Maybe SetupBuildInfo -> CheckM m ()
checkSetupBuildInfo Maybe SetupBuildInfo
Nothing = () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkSetupBuildInfo (Just (SetupBuildInfo [Dependency]
ds Bool
_)) = do
let uqs :: [UnqualComponentName]
uqs = (String -> UnqualComponentName)
-> [String] -> [UnqualComponentName]
forall a b. (a -> b) -> [a] -> [b]
map String -> UnqualComponentName
mkUnqualComponentName [String
"base", String
"Cabal"]
([Dependency]
is, [Dependency]
rs) <- [AssocDep]
-> [UnqualComponentName]
-> [Dependency]
-> CheckM m ([Dependency], [Dependency])
forall (m :: * -> *).
Monad m =>
[AssocDep]
-> [UnqualComponentName]
-> [Dependency]
-> CheckM m ([Dependency], [Dependency])
partitionDeps [] [UnqualComponentName]
uqs [Dependency]
ds
let ick :: String -> PackageCheck
ick = CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> (String -> CheckExplanation) -> String -> PackageCheck
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> CheckExplanation
UpperBoundSetup
rck :: [String] -> PackageCheck
rck =
CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn
(CheckExplanation -> PackageCheck)
-> ([String] -> CheckExplanation) -> [String] -> PackageCheck
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CEType -> [String] -> CheckExplanation
MissingUpperBounds CEType
CETSetup
(String -> PackageCheck) -> [Dependency] -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(String -> PackageCheck) -> [Dependency] -> CheckM m ()
checkPVP String -> PackageCheck
ick [Dependency]
is
([String] -> PackageCheck) -> [Dependency] -> CheckM m ()
forall (m :: * -> *).
Monad m =>
([String] -> PackageCheck) -> [Dependency] -> CheckM m ()
checkPVPs [String] -> PackageCheck
rck [Dependency]
rs
checkPackageId :: Monad m => PackageIdentifier -> CheckM m ()
checkPackageId :: forall (m :: * -> *). Monad m => PackageIdentifier -> CheckM m ()
checkPackageId (PackageIdentifier PackageName
pkgName_ Version
_pkgVersion_) = do
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Bool -> Bool
not (Bool -> Bool) -> (PackageName -> Bool) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Bool
FilePath.Windows.isValid (String -> Bool) -> (PackageName -> String) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageName -> Bool) -> PackageName -> Bool
forall a b. (a -> b) -> a -> b
$ PackageName
pkgName_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ PackageName -> CheckExplanation
InvalidNameWin PackageName
pkgName_)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP (String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isPrefixOf String
"z-" (String -> Bool) -> (PackageName -> String) -> PackageName -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageName -> String
forall a. Pretty a => a -> String
prettyShow (PackageName -> Bool) -> PackageName -> Bool
forall a b. (a -> b) -> a -> b
$ PackageName
pkgName_) (PackageCheck -> CheckM m ()) -> PackageCheck -> CheckM m ()
forall a b. (a -> b) -> a -> b
$
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
ZPrefix)
checkNewLicense :: Monad m => SPDX.License -> CheckM m ()
checkNewLicense :: forall (m :: * -> *). Monad m => License -> CheckM m ()
checkNewLicense License
lic = do
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
SPDX.NONE)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
NONELicense)
checkOldLicense
:: Monad m
=> Bool
-> License
-> CheckM m ()
checkOldLicense :: forall (m :: * -> *). Monad m => Bool -> License -> CheckM m ()
checkOldLicense Bool
nullLicFiles License
lic = do
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
UnspecifiedLicense)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
NoLicense)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
AllRightsReserved)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
AllRightsReservedLicense)
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> Bool -> PackageCheck -> CheckM m ()
checkSpecVer
CabalSpecVersion
CabalSpecV1_4
(License
lic License -> [License] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [License]
compatLicenses)
(CheckExplanation -> PackageCheck
PackageDistInexcusable (License -> CheckExplanation
LicenseMessParse License
lic))
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(License
lic License -> License -> Bool
forall a. Eq a => a -> a -> Bool
== License
BSD4)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
UncommonBSD4)
case License
lic of
UnknownLicense String
l ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP (CheckExplanation -> PackageCheck
PackageBuildWarning (String -> CheckExplanation
UnrecognisedLicense String
l))
License
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( License
lic
License -> [License] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [ License
AllRightsReserved
, License
UnspecifiedLicense
, License
PublicDomain
]
Bool -> Bool -> Bool
&&
Bool
nullLicFiles
)
(PackageCheck -> CheckM m ()) -> PackageCheck -> CheckM m ()
forall a b. (a -> b) -> a -> b
$ (CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
NoLicenseFile)
case License -> Maybe [Version]
unknownLicenseVersion License
lic of
Just [Version]
knownVersions ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP
(CheckExplanation -> PackageCheck
PackageDistSuspicious (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ License -> [Version] -> CheckExplanation
UnknownLicenseVersion License
lic [Version]
knownVersions)
Maybe [Version]
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
where
compatLicenses :: [License]
compatLicenses =
[ Maybe Version -> License
GPL Maybe Version
forall a. Maybe a
Nothing
, Maybe Version -> License
LGPL Maybe Version
forall a. Maybe a
Nothing
, Maybe Version -> License
AGPL Maybe Version
forall a. Maybe a
Nothing
, License
BSD3
, License
BSD4
, License
PublicDomain
, License
AllRightsReserved
, License
UnspecifiedLicense
, License
OtherLicense
]
unknownLicenseVersion :: License -> Maybe [Version]
unknownLicenseVersion (GPL (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | GPL (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion (LGPL (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | LGPL (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion (AGPL (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | AGPL (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion (Apache (Just Version
v))
| Version
v Version -> [Version] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`notElem` [Version]
knownVersions = [Version] -> Maybe [Version]
forall a. a -> Maybe a
Just [Version]
knownVersions
where
knownVersions :: [Version]
knownVersions = [Version
v' | Apache (Just Version
v') <- [License]
knownLicenses]
unknownLicenseVersion License
_ = Maybe [Version]
forall a. Maybe a
Nothing
checkSourceRepos :: Monad m => [SourceRepo] -> CheckM m ()
checkSourceRepos :: forall (m :: * -> *). Monad m => [SourceRepo] -> CheckM m ()
checkSourceRepos [SourceRepo]
rs = do
(SourceRepo -> CheckM m ()) -> [SourceRepo] -> CheckM m ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ SourceRepo -> CheckM m ()
forall (m :: * -> *). Monad m => SourceRepo -> CheckM m ()
repoCheck [SourceRepo]
rs
[SourceRepo] -> CheckM m ()
forall (m :: * -> *). Monad m => [SourceRepo] -> CheckM m ()
checkMissingVcsInfo [SourceRepo]
rs
where
repoCheck :: Monad m => SourceRepo -> CheckM m ()
repoCheck :: forall (m :: * -> *). Monad m => SourceRepo -> CheckM m ()
repoCheck
( SourceRepo
RepoKind
repoKind_
Maybe RepoType
repoType_
Maybe String
repoLocation_
Maybe String
repoModule_
Maybe String
_repoBranch_
Maybe String
repoTag_
Maybe String
repoSubdir_
) = do
case RepoKind
repoKind_ of
RepoKindUnknown String
kind ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> CheckExplanation
UnrecognisedSourceRepo String
kind)
RepoKind
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Maybe RepoType -> Bool
forall a. Maybe a -> Bool
isNothing Maybe RepoType
repoType_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingType)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
repoLocation_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingLocation)
Maybe String -> CheckM m ()
forall (m :: * -> *). Monad m => Maybe String -> CheckM m ()
checkGitProtocol Maybe String
repoLocation_
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
( Maybe RepoType
repoType_ Maybe RepoType -> Maybe RepoType -> Bool
forall a. Eq a => a -> a -> Bool
== RepoType -> Maybe RepoType
forall a. a -> Maybe a
Just (KnownRepoType -> RepoType
KnownRepoType KnownRepoType
CVS)
Bool -> Bool -> Bool
&& Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
repoModule_
)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingModule)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
(RepoKind
repoKind_ RepoKind -> RepoKind -> Bool
forall a. Eq a => a -> a -> Bool
== RepoKind
RepoThis Bool -> Bool -> Bool
&& Maybe String -> Bool
forall a. Maybe a -> Bool
isNothing Maybe String
repoTag_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingTag)
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
((String -> Bool) -> Maybe String -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any String -> Bool
isAbsoluteOnAnyPlatform Maybe String
repoSubdir_)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
SubdirRelPath)
case Maybe (Maybe String) -> Maybe String
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Maybe (Maybe String) -> Maybe String)
-> (Maybe String -> Maybe (Maybe String))
-> Maybe String
-> Maybe String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String -> Maybe String) -> Maybe String -> Maybe (Maybe String)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap String -> Maybe String
isGoodRelativeDirectoryPath (Maybe String -> Maybe String) -> Maybe String -> Maybe String
forall a b. (a -> b) -> a -> b
$ Maybe String
repoSubdir_ of
Just String
err ->
PackageCheck -> CheckM m ()
forall (m :: * -> *). Monad m => PackageCheck -> CheckM m ()
tellP
(CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> CheckExplanation
SubdirGoodRelPath String
err)
Maybe String
Nothing -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkMissingVcsInfo :: Monad m => [SourceRepo] -> CheckM m ()
checkMissingVcsInfo :: forall (m :: * -> *). Monad m => [SourceRepo] -> CheckM m ()
checkMissingVcsInfo [SourceRepo]
rs =
let rdirs :: [String]
rdirs = (KnownRepoType -> [String]) -> [KnownRepoType] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap KnownRepoType -> [String]
repoTypeDirname [KnownRepoType]
knownRepoTypes
in (CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
( \CheckPackageContentOps m
ops -> do
Bool
us <- [Bool] -> Bool
forall (t :: * -> *). Foldable t => t Bool -> Bool
or ([Bool] -> Bool) -> m [Bool] -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (String -> m Bool) -> [String] -> m [Bool]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesDirectoryExist CheckPackageContentOps m
ops) [String]
rdirs
Bool -> m Bool
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([SourceRepo] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [SourceRepo]
rs Bool -> Bool -> Bool
&& Bool
us)
)
(CheckExplanation -> PackageCheck
PackageDistSuspicious CheckExplanation
MissingSourceControl)
where
repoTypeDirname :: KnownRepoType -> [FilePath]
repoTypeDirname :: KnownRepoType -> [String]
repoTypeDirname KnownRepoType
Darcs = [String
"_darcs"]
repoTypeDirname KnownRepoType
Git = [String
".git"]
repoTypeDirname KnownRepoType
SVN = [String
".svn"]
repoTypeDirname KnownRepoType
CVS = [String
"CVS"]
repoTypeDirname KnownRepoType
Mercurial = [String
".hg"]
repoTypeDirname KnownRepoType
GnuArch = [String
".arch-params"]
repoTypeDirname KnownRepoType
Bazaar = [String
".bzr"]
repoTypeDirname KnownRepoType
Monotone = [String
"_MTN"]
repoTypeDirname KnownRepoType
Pijul = [String
".pijul"]
checkGitProtocol
:: Monad m
=> Maybe String
-> CheckM m ()
checkGitProtocol :: forall (m :: * -> *). Monad m => Maybe String -> CheckM m ()
checkGitProtocol Maybe String
mloc =
Bool -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
Bool -> PackageCheck -> CheckM m ()
checkP
((String -> Bool) -> Maybe String -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (String -> String -> Bool
forall a. Eq a => [a] -> [a] -> Bool
isPrefixOf String
"git://") Maybe String
mloc Maybe Bool -> Maybe Bool -> Bool
forall a. Eq a => a -> a -> Bool
== Bool -> Maybe Bool
forall a. a -> Maybe a
Just Bool
True)
(CheckExplanation -> PackageCheck
PackageBuildWarning CheckExplanation
GitProtocol)
findPackageDesc :: Monad m => CheckPackageContentOps m -> m [FilePath]
findPackageDesc :: forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> m [String]
findPackageDesc CheckPackageContentOps m
ops = do
let dir :: String
dir = String
"."
[String]
files <- CheckPackageContentOps m -> String -> m [String]
forall (m :: * -> *).
CheckPackageContentOps m -> String -> m [String]
getDirectoryContents CheckPackageContentOps m
ops String
dir
[String]
cabalFiles <-
(String -> m Bool) -> [String] -> m [String]
forall (m :: * -> *) a.
Applicative m =>
(a -> m Bool) -> [a] -> m [a]
filterM
(CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops)
[ String
dir String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</> String
file
| String
file <- [String]
files
, let (String
name, String
ext) = String -> (String, String)
splitExtension String
file
, Bool -> Bool
not (String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
name) Bool -> Bool -> Bool
&& String
ext String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
".cabal"
]
[String] -> m [String]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return [String]
cabalFiles
checkCabalFile :: Monad m => PackageName -> CheckM m ()
checkCabalFile :: forall (m :: * -> *). Monad m => PackageName -> CheckM m ()
checkCabalFile PackageName
pn = do
(CheckInterface m -> Maybe (CheckPackageContentOps m))
-> (CheckPackageContentOps m -> m [PackageCheck]) -> CheckM m ()
forall (m :: * -> *) (i :: (* -> *) -> *).
Monad m =>
(CheckInterface m -> Maybe (i m))
-> (i m -> m [PackageCheck]) -> CheckM m ()
liftInt
CheckInterface m -> Maybe (CheckPackageContentOps m)
forall (m :: * -> *).
CheckInterface m -> Maybe (CheckPackageContentOps m)
ciPackageOps
( \CheckPackageContentOps m
ops -> do
[String]
ds <- CheckPackageContentOps m -> m [String]
forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> m [String]
findPackageDesc CheckPackageContentOps m
ops
case [String]
ds of
[] -> [PackageCheck] -> m [PackageCheck]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return [CheckExplanation -> PackageCheck
PackageBuildImpossible CheckExplanation
NoDesc]
[String
d] -> do
Maybe PackageCheck
bc <- CheckPackageContentOps m -> String -> m (Maybe PackageCheck)
forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> String -> m (Maybe PackageCheck)
bomf CheckPackageContentOps m
ops String
d
[PackageCheck] -> m [PackageCheck]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Maybe PackageCheck] -> [PackageCheck]
forall a. [Maybe a] -> [a]
catMaybes [Maybe PackageCheck
bc, String -> Maybe PackageCheck
noMatch String
d])
[String]
_ -> [PackageCheck] -> m [PackageCheck]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return [CheckExplanation -> PackageCheck
PackageBuildImpossible (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ [String] -> CheckExplanation
MultiDesc [String]
ds]
)
where
bomf
:: Monad m
=> CheckPackageContentOps m
-> FilePath
-> m (Maybe PackageCheck)
bomf :: forall (m :: * -> *).
Monad m =>
CheckPackageContentOps m -> String -> m (Maybe PackageCheck)
bomf CheckPackageContentOps m
wops String
wfp = do
Bool
b <- ByteString -> ByteString -> Bool
BS.isPrefixOf ByteString
bomUtf8 (ByteString -> Bool) -> m ByteString -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CheckPackageContentOps m -> String -> m ByteString
forall (m :: * -> *).
CheckPackageContentOps m -> String -> m ByteString
getFileContents CheckPackageContentOps m
wops String
wfp
if Bool
b
then (Maybe PackageCheck -> m (Maybe PackageCheck)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Maybe PackageCheck -> m (Maybe PackageCheck))
-> (PackageCheck -> Maybe PackageCheck)
-> PackageCheck
-> m (Maybe PackageCheck)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PackageCheck -> Maybe PackageCheck
forall a. a -> Maybe a
Just) (CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> CheckExplanation
BOMStart String
wfp)
else Maybe PackageCheck -> m (Maybe PackageCheck)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe PackageCheck
forall a. Maybe a
Nothing
bomUtf8 :: BS.ByteString
bomUtf8 :: ByteString
bomUtf8 = [Word8] -> ByteString
BS.pack [Word8
0xef, Word8
0xbb, Word8
0xbf]
noMatch :: FilePath -> Maybe PackageCheck
noMatch :: String -> Maybe PackageCheck
noMatch String
wd =
let expd :: String
expd = PackageName -> String
unPackageName PackageName
pn String -> String -> String
forall p. FileLike p => p -> String -> p
<.> String
"cabal"
in if String -> String
takeFileName String
wd String -> String -> Bool
forall a. Eq a => a -> a -> Bool
/= String
expd
then PackageCheck -> Maybe PackageCheck
forall a. a -> Maybe a
Just (CheckExplanation -> PackageCheck
PackageDistInexcusable (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> String -> CheckExplanation
NotPackageName String
wd String
expd)
else Maybe PackageCheck
forall a. Maybe a
Nothing
checkLicFileExist
:: Monad m
=> RelativePath Pkg File
-> CheckM m ()
checkLicFileExist :: forall (m :: * -> *).
Monad m =>
RelativePath Pkg 'File -> CheckM m ()
checkLicFileExist RelativePath Pkg 'File
sp = do
let fp :: String
fp = RelativePath Pkg 'File -> String
forall (allowAbsolute :: AllowAbsolute) from (to :: FileOrDir).
SymbolicPathX allowAbsolute from to -> String
getSymbolicPath RelativePath Pkg 'File
sp
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
(\CheckPackageContentOps m
ops -> Bool -> Bool
not (Bool -> Bool) -> m Bool -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops String
fp)
(CheckExplanation -> PackageCheck
PackageBuildWarning (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> RelativePath Pkg 'File -> CheckExplanation
UnknownFile String
"license-file" RelativePath Pkg 'File
sp)
checkConfigureExists :: Monad m => BuildType -> CheckM m ()
checkConfigureExists :: forall (m :: * -> *). Monad m => BuildType -> CheckM m ()
checkConfigureExists BuildType
Configure =
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
(\CheckPackageContentOps m
ops -> Bool -> Bool
not (Bool -> Bool) -> m Bool -> m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops String
"configure")
(CheckExplanation -> PackageCheck
PackageBuildWarning CheckExplanation
MissingConfigureScript)
checkConfigureExists BuildType
_ = () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkSetupExists :: Monad m => BuildType -> CheckM m ()
checkSetupExists :: forall (m :: * -> *). Monad m => BuildType -> CheckM m ()
checkSetupExists BuildType
Simple = () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
checkSetupExists BuildType
_ =
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
forall (m :: * -> *).
Monad m =>
(CheckPackageContentOps m -> m Bool) -> PackageCheck -> CheckM m ()
checkPkg
( \CheckPackageContentOps m
ops -> do
Bool
ba <- CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops String
"Setup.hs"
Bool
bb <- CheckPackageContentOps m -> String -> m Bool
forall (m :: * -> *). CheckPackageContentOps m -> String -> m Bool
doesFileExist CheckPackageContentOps m
ops String
"Setup.lhs"
Bool -> m Bool
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool -> Bool
not (Bool -> Bool) -> Bool -> Bool
forall a b. (a -> b) -> a -> b
$ Bool
ba Bool -> Bool -> Bool
|| Bool
bb)
)
(CheckExplanation -> PackageCheck
PackageDistInexcusable CheckExplanation
MissingSetupFile)
checkGlobFile
:: Monad m
=> CabalSpecVersion
-> FilePath
-> FilePath
-> CabalField
-> CheckM m ()
checkGlobFile :: forall (m :: * -> *).
Monad m =>
CabalSpecVersion -> String -> String -> String -> CheckM m ()
checkGlobFile CabalSpecVersion
cv String
ddir String
title String
fp = do
let adjDdir :: String
adjDdir = if String -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null String
ddir then String
"." else String
ddir
dir :: String
dir
| String
title String -> String -> Bool
forall a. Eq a => a -> a -> Bool
== String
"data-files" = String
adjDdir
| Bool
otherwise = String
"."
case CabalSpecVersion -> String -> Either GlobSyntaxError Glob
parseFileGlob CabalSpecVersion
cv String
fp of
Left GlobSyntaxError
_ -> () -> CheckM m ()
forall a. a -> CheckM m a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
Right Glob
parsedGlob -> do
(CheckInterface m -> Maybe (CheckPreDistributionOps m))
-> (CheckPreDistributionOps m -> m [PackageCheck]) -> CheckM m ()
forall (m :: * -> *) (i :: (* -> *) -> *).
Monad m =>
(CheckInterface m -> Maybe (i m))
-> (i m -> m [PackageCheck]) -> CheckM m ()
liftInt CheckInterface m -> Maybe (CheckPreDistributionOps m)
forall (m :: * -> *).
CheckInterface m -> Maybe (CheckPreDistributionOps m)
ciPreDistOps ((CheckPreDistributionOps m -> m [PackageCheck]) -> CheckM m ())
-> (CheckPreDistributionOps m -> m [PackageCheck]) -> CheckM m ()
forall a b. (a -> b) -> a -> b
$ \CheckPreDistributionOps m
po -> do
[GlobResult String]
rs <- CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
forall (m :: * -> *).
CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
runDirFileGlobM CheckPreDistributionOps m
po String
dir Glob
parsedGlob
[PackageCheck] -> m [PackageCheck]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([PackageCheck] -> m [PackageCheck])
-> [PackageCheck] -> m [PackageCheck]
forall a b. (a -> b) -> a -> b
$ String -> String -> [GlobResult String] -> [PackageCheck]
checkGlobResult String
title String
fp [GlobResult String]
rs
checkGlobResult
:: CabalField
-> FilePath
-> [GlobResult FilePath]
-> [PackageCheck]
checkGlobResult :: String -> String -> [GlobResult String] -> [PackageCheck]
checkGlobResult String
title String
fp [GlobResult String]
rs = [PackageCheck]
dirCheck [PackageCheck] -> [PackageCheck] -> [PackageCheck]
forall a. [a] -> [a] -> [a]
++ [Maybe PackageCheck] -> [PackageCheck]
forall a. [Maybe a] -> [a]
catMaybes ((GlobResult String -> Maybe PackageCheck)
-> [GlobResult String] -> [Maybe PackageCheck]
forall a b. (a -> b) -> [a] -> [b]
map GlobResult String -> Maybe PackageCheck
getWarning [GlobResult String]
rs)
where
dirCheck :: [PackageCheck]
dirCheck
| (GlobResult String -> Bool) -> [GlobResult String] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all (Bool -> Bool
not (Bool -> Bool)
-> (GlobResult String -> Bool) -> GlobResult String -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. GlobResult String -> Bool
forall {a}. GlobResult a -> Bool
withoutNoMatchesWarning) [GlobResult String]
rs =
[CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$ String -> String -> CheckExplanation
GlobNoMatch String
title String
fp]
| Bool
otherwise = []
withoutNoMatchesWarning :: GlobResult a -> Bool
withoutNoMatchesWarning (GlobMatch a
_) = Bool
True
withoutNoMatchesWarning (GlobWarnMultiDot a
_) = Bool
False
withoutNoMatchesWarning (GlobMissingDirectory a
_) = Bool
True
withoutNoMatchesWarning (GlobMatchesDirectory a
_) = Bool
True
getWarning :: GlobResult FilePath -> Maybe PackageCheck
getWarning :: GlobResult String -> Maybe PackageCheck
getWarning (GlobMatch String
_) = Maybe PackageCheck
forall a. Maybe a
Nothing
getWarning (GlobWarnMultiDot String
file) =
PackageCheck -> Maybe PackageCheck
forall a. a -> Maybe a
Just (PackageCheck -> Maybe PackageCheck)
-> PackageCheck -> Maybe PackageCheck
forall a b. (a -> b) -> a -> b
$ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (String -> String -> String -> CheckExplanation
GlobExactMatch String
title String
fp String
file)
getWarning (GlobMissingDirectory String
dir) =
PackageCheck -> Maybe PackageCheck
forall a. a -> Maybe a
Just (PackageCheck -> Maybe PackageCheck)
-> PackageCheck -> Maybe PackageCheck
forall a b. (a -> b) -> a -> b
$ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (String -> String -> String -> CheckExplanation
GlobNoDir String
title String
fp String
dir)
getWarning (GlobMatchesDirectory String
_) = Maybe PackageCheck
forall a. Maybe a
Nothing
wrapParseWarning :: FilePath -> PWarning -> PackageCheck
wrapParseWarning :: String -> PWarning -> PackageCheck
wrapParseWarning String
fp PWarning
pw = CheckExplanation -> PackageCheck
PackageDistSuspicious (String -> PWarning -> CheckExplanation
ParseWarning String
fp PWarning
pw)
extractAssocDeps
:: UnqualComponentName
-> CondTree ConfVar [Dependency] Library
-> AssocDep
UnqualComponentName
n CondTree ConfVar [Dependency] Library
ct =
let a :: (Library, [Dependency])
a = CondTree ConfVar [Dependency] Library -> (Library, [Dependency])
forall a c v.
(Semigroup a, Semigroup c) =>
CondTree v c a -> (a, c)
ignoreConditions CondTree ConfVar [Dependency] Library
ct
in
(UnqualComponentName
n, (Library, [Dependency]) -> [Dependency]
forall a b. (a, b) -> b
snd (Library, [Dependency])
a)
pd2gpd :: PackageDescription -> GenericPackageDescription
pd2gpd :: PackageDescription -> GenericPackageDescription
pd2gpd PackageDescription
pd = GenericPackageDescription
gpd
where
gpd :: GenericPackageDescription
gpd :: GenericPackageDescription
gpd =
GenericPackageDescription
emptyGenericPackageDescription
{ packageDescription = pd
, condLibrary = fmap t2c (library pd)
, condSubLibraries = map (t2cName ln id) (subLibraries pd)
, condForeignLibs =
map
(t2cName foreignLibName id)
(foreignLibs pd)
, condExecutables =
map
(t2cName exeName id)
(executables pd)
, condTestSuites =
map
(t2cName testName remTest)
(testSuites pd)
, condBenchmarks =
map
(t2cName benchmarkName remBench)
(benchmarks pd)
}
t2c :: a -> CondTree ConfVar [Dependency] a
t2c :: forall a. a -> CondTree ConfVar [Dependency] a
t2c a
a = a
-> [Dependency]
-> [CondBranch ConfVar [Dependency] a]
-> CondTree ConfVar [Dependency] a
forall v c a. a -> c -> [CondBranch v c a] -> CondTree v c a
CondNode a
a [] []
t2cName
:: (a -> UnqualComponentName)
-> (a -> a)
-> a
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
t2cName :: forall a.
(a -> UnqualComponentName)
-> (a -> a)
-> a
-> (UnqualComponentName, CondTree ConfVar [Dependency] a)
t2cName a -> UnqualComponentName
nf a -> a
mf a
a = (a -> UnqualComponentName
nf a
a, a -> CondTree ConfVar [Dependency] a
forall a. a -> CondTree ConfVar [Dependency] a
t2c (a -> CondTree ConfVar [Dependency] a)
-> (a -> a) -> a -> CondTree ConfVar [Dependency] a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> a
mf (a -> CondTree ConfVar [Dependency] a)
-> a -> CondTree ConfVar [Dependency] a
forall a b. (a -> b) -> a -> b
$ a
a)
ln :: Library -> UnqualComponentName
ln :: Library -> UnqualComponentName
ln Library
wl = case Library -> LibraryName
libName Library
wl of
(LSubLibName UnqualComponentName
u) -> UnqualComponentName
u
LibraryName
LMainLibName -> String -> UnqualComponentName
mkUnqualComponentName String
"main-library"
remTest :: TestSuite -> TestSuite
remTest :: TestSuite -> TestSuite
remTest TestSuite
t = TestSuite
t{testName = mempty}
remBench :: Benchmark -> Benchmark
remBench :: Benchmark -> Benchmark
remBench Benchmark
b = Benchmark
b{benchmarkName = mempty}
checkMissingDocs
:: Monad m
=> [Glob]
-> [Glob]
-> [Glob]
-> [Glob]
-> CheckM m ()
checkMissingDocs :: forall (m :: * -> *).
Monad m =>
[Glob] -> [Glob] -> [Glob] -> [Glob] -> CheckM m ()
checkMissingDocs [Glob]
dgs [Glob]
esgs [Glob]
edgs [Glob]
efgs = do
Bool
extraDocSupport <- (CabalSpecVersion -> CabalSpecVersion -> Bool
forall a. Ord a => a -> a -> Bool
>= CabalSpecVersion
CabalSpecV1_18) (CabalSpecVersion -> Bool)
-> CheckM m CabalSpecVersion -> CheckM m Bool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (CheckCtx m -> CabalSpecVersion) -> CheckM m CabalSpecVersion
forall (m :: * -> *) a. Monad m => (CheckCtx m -> a) -> CheckM m a
asksCM CheckCtx m -> CabalSpecVersion
forall (m :: * -> *). CheckCtx m -> CabalSpecVersion
ccSpecVersion
(CheckInterface m -> Maybe (CheckPreDistributionOps m))
-> (CheckPreDistributionOps m -> m [PackageCheck]) -> CheckM m ()
forall (m :: * -> *) (i :: (* -> *) -> *).
Monad m =>
(CheckInterface m -> Maybe (i m))
-> (i m -> m [PackageCheck]) -> CheckM m ()
liftInt
CheckInterface m -> Maybe (CheckPreDistributionOps m)
forall (m :: * -> *).
CheckInterface m -> Maybe (CheckPreDistributionOps m)
ciPreDistOps
( \CheckPreDistributionOps m
ops -> do
[String]
rootContents <- CheckPreDistributionOps m -> String -> m [String]
forall (m :: * -> *).
CheckPreDistributionOps m -> String -> m [String]
getDirectoryContentsM CheckPreDistributionOps m
ops String
"."
let des :: [String]
des = (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter String -> Bool
isDesirableExtraDocFile [String]
rootContents
let realGlob :: t Glob -> m [String]
realGlob t Glob
t =
([GlobResult String] -> [String])
-> t [GlobResult String] -> [String]
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
concatMap [GlobResult String] -> [String]
forall a. [GlobResult a] -> [a]
globMatches
(t [GlobResult String] -> [String])
-> m (t [GlobResult String]) -> m [String]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Glob -> m [GlobResult String])
-> t Glob -> m (t [GlobResult String])
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> t a -> m (t b)
mapM (CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
forall (m :: * -> *).
CheckPreDistributionOps m
-> String -> Glob -> m [GlobResult String]
runDirFileGlobM CheckPreDistributionOps m
ops String
"") t Glob
t
[String]
rgs <- [Glob] -> m [String]
forall {t :: * -> *}. Traversable t => t Glob -> m [String]
realGlob [Glob]
dgs
[String]
res <- [Glob] -> m [String]
forall {t :: * -> *}. Traversable t => t Glob -> m [String]
realGlob [Glob]
esgs
[String]
red <- [Glob] -> m [String]
forall {t :: * -> *}. Traversable t => t Glob -> m [String]
realGlob [Glob]
edgs
[String]
ref <- [Glob] -> m [String]
forall {t :: * -> *}. Traversable t => t Glob -> m [String]
realGlob [Glob]
efgs
let mcs :: [PackageCheck]
mcs = Bool -> [String] -> [String] -> [PackageCheck]
checkDoc Bool
extraDocSupport [String]
des ([String]
rgs [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
res [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
red [String] -> [String] -> [String]
forall a. [a] -> [a] -> [a]
++ [String]
ref)
let pcsData :: [PackageCheck]
pcsData = Bool -> String -> [String] -> [String] -> [PackageCheck]
checkDocMove Bool
extraDocSupport String
"data-files" [String]
des [String]
rgs
pcsSource :: [PackageCheck]
pcsSource =
if Bool
extraDocSupport
then
Bool -> String -> [String] -> [String] -> [PackageCheck]
checkDocMove
Bool
extraDocSupport
String
"extra-source-files"
[String]
des
[String]
res
else []
pcs :: [PackageCheck]
pcs = [PackageCheck]
pcsData [PackageCheck] -> [PackageCheck] -> [PackageCheck]
forall a. [a] -> [a] -> [a]
++ [PackageCheck]
pcsSource
[PackageCheck] -> m [PackageCheck]
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ([PackageCheck]
mcs [PackageCheck] -> [PackageCheck] -> [PackageCheck]
forall a. [a] -> [a] -> [a]
++ [PackageCheck]
pcs)
)
where
checkDoc
:: Bool
-> [FilePath]
-> [FilePath]
-> [PackageCheck]
checkDoc :: Bool -> [String] -> [String] -> [PackageCheck]
checkDoc Bool
b [String]
ds [String]
as =
let fds :: [String]
fds = (String -> String) -> [String] -> [String]
forall a b. (a -> b) -> [a] -> [b]
map (String
"." String -> String -> String
forall p q r. PathLike p q r => p -> q -> r
</>) ([String] -> [String]) -> [String] -> [String]
forall a b. (a -> b) -> a -> b
$ (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool) -> [String] -> String -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> [String] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
notElem [String]
as) [String]
ds
in if [String] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
fds
then []
else
[ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$
Bool -> [String] -> CheckExplanation
MissingExpectedDocFiles Bool
b [String]
fds
]
checkDocMove
:: Bool
-> CabalField
-> [FilePath]
-> [FilePath]
-> [PackageCheck]
checkDocMove :: Bool -> String -> [String] -> [String] -> [PackageCheck]
checkDocMove Bool
b String
field [String]
ds [String]
as =
let fds :: [String]
fds = (String -> Bool) -> [String] -> [String]
forall a. (a -> Bool) -> [a] -> [a]
filter ((String -> [String] -> Bool) -> [String] -> String -> Bool
forall a b c. (a -> b -> c) -> b -> a -> c
flip String -> [String] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
elem [String]
as) [String]
ds
in if [String] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [String]
fds
then []
else
[ CheckExplanation -> PackageCheck
PackageDistSuspiciousWarn (CheckExplanation -> PackageCheck)
-> CheckExplanation -> PackageCheck
forall a b. (a -> b) -> a -> b
$
Bool -> String -> [String] -> CheckExplanation
WrongFieldForExpectedDocFiles Bool
b String
field [String]
fds
]
isDesirableExtraDocFile :: FilePath -> Bool
String
path =
String
basename String -> [String] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
desirableChangeLog
Bool -> Bool -> Bool
&& String
ext String -> [String] -> Bool
forall a. Eq a => a -> [a] -> Bool
forall (t :: * -> *) a. (Foldable t, Eq a) => a -> t a -> Bool
`elem` [String]
desirableChangeLogExtensions
where
(String
basename, String
ext) = String -> (String, String)
splitExtension ((Char -> Char) -> String -> String
forall a b. (a -> b) -> [a] -> [b]
map Char -> Char
toLower String
path)
desirableChangeLog :: [String]
desirableChangeLog = [String
"news", String
"changelog", String
"change_log", String
"changes"]
desirableChangeLogExtensions :: [String]
desirableChangeLogExtensions = [String
"", String
".txt", String
".md", String
".markdown", String
".rst"]
dups :: Ord a => [a] -> [a]
dups :: forall a. Ord a => [a] -> [a]
dups [a]
xs = [a
x | (a
x : a
_ : [a]
_) <- [a] -> [[a]]
forall a. Eq a => [a] -> [[a]]
group ([a] -> [a]
forall a. Ord a => [a] -> [a]
sort [a]
xs)]