From bc969bc46dd4259e7fbd4c62ba28c4671203fdb4 Mon Sep 17 00:00:00 2001 From: Decio Ferreira Date: Wed, 11 Dec 2024 22:28:58 +0000 Subject: [PATCH] extend elm-review rules --- review/src/ReviewConfig.elm | 12 +++++------ src/Data/Map.elm | 2 +- src/System/IO.elm | 42 ++++++++++++++++++++++++++++++++++++- src/Utils/Main.elm | 1 - 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/review/src/ReviewConfig.elm b/review/src/ReviewConfig.elm index a6ca4c0a7..12848e065 100644 --- a/review/src/ReviewConfig.elm +++ b/review/src/ReviewConfig.elm @@ -38,9 +38,8 @@ config = [ Docs.ReviewAtDocs.rule , NoConfusingPrefixOperator.rule , NoDebug.Log.rule - - -- , NoDebug.TodoOrToString.rule - -- |> Rule.ignoreErrorsForDirectories [ "tests/" ] + , NoDebug.TodoOrToString.rule + |> Rule.ignoreErrorsForDirectories [ "tests/" ] , NoExposingEverything.rule , NoImportingEverything.rule [] , NoMissingTypeAnnotation.rule @@ -54,8 +53,9 @@ config = , NoUnused.Dependencies.rule -- , NoUnused.Exports.rule - -- , NoUnused.Parameters.rule - -- , NoUnused.Patterns.rule - -- , NoUnused.Variables.rule + , NoUnused.Parameters.rule + |> Rule.ignoreErrorsForFiles [ "src/Utils/Crash.elm" ] + , NoUnused.Patterns.rule + , NoUnused.Variables.rule , Simplify.rule Simplify.defaults ] diff --git a/src/Data/Map.elm b/src/Data/Map.elm index af2e0f30e..1c4a8a23a 100644 --- a/src/Data/Map.elm +++ b/src/Data/Map.elm @@ -277,7 +277,7 @@ merge : -> Dict comparable k b -> result -> result -merge keyComparison leftStep bothStep rightStep (D leftDict) (D rightDict) initialResult = +merge _ leftStep bothStep rightStep (D leftDict) (D rightDict) initialResult = Dict.merge (\_ ( k, a ) -> leftStep k a) (\_ ( k, a ) ( _, b ) -> bothStep k a b) diff --git a/src/System/IO.elm b/src/System/IO.elm index acda3e0dc..1792bfc0c 100644 --- a/src/System/IO.elm +++ b/src/System/IO.elm @@ -137,6 +137,10 @@ run app = , recvDirCanonicalizePath (\{ index, value } -> DirCanonicalizePathMsg index value) , recvBinaryDecodeFileOrFail (\{ index, value } -> BinaryDecodeFileOrFailMsg index value) , recvWrite WriteMsg + , recvDirRemoveFile DirRemoveFileMsg + , recvDirRemoveDirectoryRecursive DirRemoveDirectoryRecursiveMsg + , recvDirWithCurrentDirectory DirWithCurrentDirectoryMsg + , recvReplGetInputLineWithInitial (\{ index, value } -> ReplGetInputLineWithInitialMsg index value) , recvNewEmptyMVar (\{ index, value } -> NewEmptyMVarMsg index value) , recvReadMVar (\{ index, value } -> ReadMVarMsg index value) , recvPutMVar PutMVarMsg @@ -212,6 +216,10 @@ type Msg | DirCanonicalizePathMsg Int FilePath | BinaryDecodeFileOrFailMsg Int Encode.Value | WriteMsg Int + | DirRemoveFileMsg Int + | DirRemoveDirectoryRecursiveMsg Int + | DirWithCurrentDirectoryMsg Int + | ReplGetInputLineWithInitialMsg Int (Maybe String) | NewEmptyMVarMsg Int Int | ReadMVarMsg Int Encode.Value | PutMVarMsg Int @@ -575,6 +583,38 @@ update msg model = _ -> crash "WriteMsg" + DirRemoveFileMsg index -> + case Dict.get index model.next of + Just (DirRemoveFileNext fn) -> + update (PureMsg index (fn ())) model + + _ -> + crash "DirRemoveFileMsg" + + DirRemoveDirectoryRecursiveMsg index -> + case Dict.get index model.next of + Just (DirRemoveDirectoryRecursiveNext fn) -> + update (PureMsg index (fn ())) model + + _ -> + crash "DirRemoveDirectoryRecursiveMsg" + + DirWithCurrentDirectoryMsg index -> + case Dict.get index model.next of + Just (DirWithCurrentDirectoryNext fn) -> + update (PureMsg index (fn ())) model + + _ -> + crash "DirWithCurrentDirectoryMsg" + + ReplGetInputLineWithInitialMsg index value -> + case Dict.get index model.next of + Just (ReplGetInputLineWithInitialNext fn) -> + update (PureMsg index (fn value)) model + + _ -> + crash "ReplGetInputLineWithInitialMsg" + port sendGetLine : Int -> Cmd msg @@ -744,7 +784,7 @@ port recvDirWithCurrentDirectory : (Int -> msg) -> Sub msg port sendReplGetInputLineWithInitial : { index : Int, prompt : String, left : String, right : String } -> Cmd msg -port recvReplGetInputLineWithInitial : (Maybe String -> msg) -> Sub msg +port recvReplGetInputLineWithInitial : ({ index : Int, value : Maybe String } -> msg) -> Sub msg diff --git a/src/Utils/Main.elm b/src/Utils/Main.elm index e52a41709..9cbcffbb0 100644 --- a/src/Utils/Main.elm +++ b/src/Utils/Main.elm @@ -127,7 +127,6 @@ import Basics.Extra exposing (flip) import Builder.Reporting.Task as Task exposing (Task) import Compiler.Data.Index as Index import Compiler.Data.NonEmptyList as NE -import Compiler.Elm.Version exposing (toComparable) import Compiler.Json.Decode as D import Compiler.Json.Encode as E import Compiler.Reporting.Result as R