<commit_before>{-# LANGUAGE PatternGuards, ViewPatterns #-}

module Settings(
    Severity(..), Note(..), showNotes, FuncName, Setting(..), isClassify, isMatchExp,
    defaultHintName, isUnifyVar,
    readSettings, readPragma, findSettings
    ) where

import HSE.All
import Data.Char
import Data.List
import System.FilePath
import Util


defaultHintName = "Use alternative"


-- | How severe an error is.
data Severity
    = Ignore -- ^ Ignored errors are only returned when @--show@ is passed.
    | Warning -- ^ Warnings are things that some people may consider improvements, but some may not.
    | Error -- ^ Errors are suggestions that should nearly always be a good idea to apply.
      deriving (Eq,Ord,Show,Read,Bounded,Enum)

getSeverity :: String -> Maybe Severity
getSeverity "ignore" = Just Ignore
getSeverity "warn" = Just Warning
getSeverity "warning" = Just Warning
getSeverity "error"  = Just Error
getSeverity "hint"  = Just Error
getSeverity _ = Nothing


-- (modulename,functionname)
-- either being blank implies universal matching
type FuncName = (String,String)

<commit_msg>Add a type signature to something I export<commit_after>{-# LANGUAGE PatternGuards, ViewPatterns #-}

module Settings(
    Severity(..), Note(..), showNotes, FuncName, Setting(..), isClassify, isMatchExp,
    defaultHintName, isUnifyVar,
    readSettings, readPragma, findSettings
    ) where

import HSE.All
import Data.Char
import Data.List
import System.FilePath
import Util


defaultHintName :: String
defaultHintName = "Use alternative"


-- | How severe an error is.
data Severity
    = Ignore -- ^ Ignored errors are only returned when @--show@ is passed.
    | Warning -- ^ Warnings are things that some people may consider improvements, but some may not.
    | Error -- ^ Errors are suggestions that should nearly always be a good idea to apply.
      deriving (Eq,Ord,Show,Read,Bounded,Enum)

getSeverity :: String -> Maybe Severity
getSeverity "ignore" = Just Ignore
getSeverity "warn" = Just Warning
getSeverity "warning" = Just Warning
getSeverity "error"  = Just Error
getSeverity "hint"  = Just Error
getSeverity _ = Nothing


-- (modulename,functionname)
-- either being blank implies universal matching
type FuncName = (String,String)


{'fraction_non_alphanumeric': 0.09329187027987561, 'fraction_numerical': 0.0, 'mean_word_length': 4.038031319910514, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6091238', 'n_tokens_mistral': 682, 'n_tokens_neox': 666, 'n_words': 239}