refactor(hlint): Demote Environment-from-OS to a suggestion

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8092
GitOrigin-RevId: 042aec936638fcb7890ecaa8cb368ed442100904
This commit is contained in:
Philip Lykke Carlsen 2023-02-23 22:43:08 +01:00 committed by hasura-bot
parent 0271094df7
commit 1af8d53c6f
4 changed files with 15 additions and 10 deletions

View File

@ -31,14 +31,6 @@
- functions:
- name: "System.Environment.getEnvironment"
within: ["Harness.**", "Main", "Spec.**", "SpecHook", "Test.**"]
message: "Instead of 'getEnvironment', use the environment from the server context"
- name: "Data.Environment.getEnvironment"
within: ["Harness.**", "Main", "Spec.**", "SpecHook", "Test.**"]
message: "Instead of 'getEnvironment', use the environment from the server context"
- name: "Test.Hspec.focus"
within: []
message: "Specs with focusing should only be used during development"
@ -246,6 +238,16 @@
- error: {lhs: "Control.Concurrent.threadDelay", rhs: "Control.Concurrent.Extended.sleep", note: "Please use `sleep` instead (and read the docs!)"}
- suggest: {lhs: "Control.Concurrent.Async.Lifted.Safe.async", rhs: "Control.Concurrent.Async.Lifted.Safe.withAsync", note: "Please use 'Control.Control.Concurrent.Async.Lifted.Safe.withAsync' or our 'forkImmortal' instead for more robust threading."}
- suggest: {lhs: "Control.Concurrent.forkIO", rhs: "Control.Concurrent.Async.Lifted.Safe.withAsync", note: "Please use 'Control.Control.Concurrent.Async.Lifted.Safe.withAsync' or our 'forkImmortal' instead for more robust threading."}
- suggest: {
lhs: "System.Environment.getEnvironment",
rhs: "env_from_function_argument",
note: "Instead of 'getEnvironment', use the environment from the server context, typically accessible as a function argument"
}
- suggest: {
lhs: "Data.Environment.getEnvironment",
rhs: "env_from_function_argument",
note: "Instead of 'getEnvironment', use the environment from the server context, typically accessible as a function argument"
}
- ignore: {
group: {name: "unsafe"},

View File

@ -36,7 +36,7 @@ import System.Exit qualified as Sys
import System.Metrics qualified as EKG
import System.Posix.Signals qualified as Signals
{-# ANN main ("HLint: ignore Avoid restricted function" :: String) #-}
{-# ANN main ("HLINT: ignore Use env_from_function_argument" :: String) #-}
main :: IO ()
main = maybeWithGhcDebug $ do
catch

View File

@ -1,3 +1,5 @@
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
module Data.Environment
( Environment (),
getEnvironment,
@ -21,7 +23,7 @@ newtype Environment = Environment (M.Map String String) deriving (Eq, Show, Gene
instance FromJSON Environment
-- 'getEnvironment' is allowed to use 'System.Environment.getEnvironment'
{-# ANN getEnvironment ("HLINT: ignore Avoid restricted function" :: String) #-}
{-# ANN getEnvironment ("HLINT: ignore Use env_from_function_argument" :: String) #-}
getEnvironment :: IO Environment
getEnvironment = mkEnvironment <$> System.Environment.getEnvironment

View File

@ -49,6 +49,7 @@ import Test.Hasura.Server.MigrateSuite qualified as MigrateSuite
import Test.Hasura.StreamingSubscriptionSuite qualified as StreamingSubscriptionSuite
import Test.Hspec
{-# ANN main ("HLINT: ignore Use env_from_function_argument" :: String) #-}
main :: IO ()
main = do
env <- getEnvironment