Skip to content

Commit

Permalink
Review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dillonkearns committed May 10, 2023
1 parent 24e4587 commit b01ec4c
Show file tree
Hide file tree
Showing 21 changed files with 34 additions and 159 deletions.
1 change: 1 addition & 0 deletions review/src/ReviewConfig.elm
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ config =
, "src/TestResult.elm"
, "src/Parser/Extra/String.elm"
]
|> Rule.ignoreErrorsForFiles [ "src/Stub.elm" ]
)


Expand Down
8 changes: 4 additions & 4 deletions src/BackendTask/Internal/Request.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module BackendTask.Internal.Request exposing (request, request2)

import BackendTask exposing (BackendTask)
import BackendTask.Http exposing (Body, Error(..), Expect)
import BackendTask.Http exposing (Body, Expect)
import Json.Decode exposing (Decoder)
import Json.Encode as Encode

Expand All @@ -24,7 +24,7 @@ request ({ name, body, expect } as params) =
}
expect
|> BackendTask.onError
(\error ->
(\_ ->
-- TODO avoid crash here, this should be handled as an internal error
request params
)
Expand All @@ -38,7 +38,7 @@ request2 :
, onError : Json.Decode.Error -> error
}
-> BackendTask error a
request2 ({ name, body, expect, onError, errorDecoder } as params) =
request2 { name, body, expect, onError, errorDecoder } =
-- elm-review: known-unoptimized-recursion
BackendTask.Http.request
{ url = "elm-pages-internal://" ++ name
Expand All @@ -50,7 +50,7 @@ request2 ({ name, body, expect, onError, errorDecoder } as params) =
}
(BackendTask.Http.expectJson Json.Decode.value)
|> BackendTask.onError
(\error ->
(\_ ->
BackendTask.succeed Encode.null
)
|> BackendTask.andThen
Expand Down
19 changes: 0 additions & 19 deletions src/Internal/Field.elm

This file was deleted.

81 changes: 0 additions & 81 deletions src/Internal/Input.elm

This file was deleted.

4 changes: 2 additions & 2 deletions src/Pages/Form.elm
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Dict exposing (Dict)
import FatalError exposing (FatalError)
import Form
import Form.Handler
import Form.Validation as Validation exposing (Validation)
import Form.Validation exposing (Validation)
import Html
import Html.Styled
import Pages.Internal.Msg
Expand All @@ -42,7 +42,7 @@ type alias FormWithServerValidations error combined input view =

{-| -}
type alias Handler error combined =
Form.Handler.Handler error (BackendTask FatalError (Validation.Validation error combined Never Never))
Form.Handler.Handler error (BackendTask FatalError (Validation error combined Never Never))


{-| -}
Expand Down
19 changes: 7 additions & 12 deletions src/Pages/Internal/Msg.elm
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
module Pages.Internal.Msg exposing
( Msg(..)
--, fetcherOnSubmit

, map
--, onSubmit
--, submitIfValid

( Msg(..)
--, fetcherOnSubmit
, map
--, onSubmit
--, submitIfValid
)

--import Form.FormData exposing (FormData)
--import FormDecoder

import Form exposing (Method)
import Html exposing (Attribute)
import Html.Attributes as Attr
import Json.Decode


{-| -}
Expand Down Expand Up @@ -75,6 +70,7 @@ type Msg userMsg
{-| -}
map : (a -> b) -> Msg a -> Msg b
map mapFn msg =
-- elm-review: known-unoptimized-recursion
case msg of
UserMsg userMsg ->
UserMsg (mapFn userMsg)
Expand All @@ -91,8 +87,7 @@ map mapFn msg =
}

FormMsg value ->
FormMsg
(Form.mapMsg (map mapFn) value)
FormMsg (Form.mapMsg (map mapFn) value)

NoOp ->
NoOp
20 changes: 10 additions & 10 deletions src/Pages/Internal/Platform.elm
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,16 @@ update config appMsg model =
|> performUserMsg userMsg config

Pages.Internal.Msg.Submit fields ->
let
payload : { fields : List ( String, String ), method : Form.Method, action : String, id : Maybe String }
payload =
{ fields = fields.fields
, method = fields.method
, action = fields.action
, id = Just fields.id
}
in
if fields.valid then
let
payload : { fields : List ( String, String ), method : Form.Method, action : String, id : Maybe String }
payload =
{ fields = fields.fields
, method = fields.method
, action = fields.action
, id = Just fields.id
}
in
if fields.useFetcher then
( { model | nextTransitionKey = model.nextTransitionKey + 1 }
, SubmitFetcher fields.id model.nextTransitionKey payload
Expand Down Expand Up @@ -988,7 +988,7 @@ perform config model effect =
, fromPageMsg = Pages.Internal.Msg.UserMsg >> UserMsg
, key = key
, setField =
\info ->
\_ ->
--Task.succeed (SetField info) |> Task.perform identity
-- TODO
Cmd.none
Expand Down
2 changes: 1 addition & 1 deletion src/Pages/Internal/Platform/GeneratorApplication.elm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type alias JsonValue =

{-| -}
type alias Program =
Program.StatefulProgram Model Msg (BackendTask FatalError.FatalError ()) Flags
Program.StatefulProgram Model Msg (BackendTask FatalError ()) Flags


{-| -}
Expand Down
10 changes: 1 addition & 9 deletions src/Pages/Internal/Platform/StaticResponses.elm
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), empty, nextStep, renderApiRequest)
module Pages.Internal.Platform.StaticResponses exposing (NextStep(..), empty, nextStep)

import BackendTask exposing (BackendTask)
import BuildError exposing (BuildError)
import FatalError exposing (FatalError)
import List.Extra
import Pages.Internal.FatalError
import Pages.StaticHttp.Request as HashRequest
import Pages.StaticHttpRequest as StaticHttpRequest
Expand All @@ -16,13 +15,6 @@ empty a =
BackendTask.succeed a


renderApiRequest :
BackendTask FatalError response
-> BackendTask FatalError response
renderApiRequest request =
request


type NextStep route value
= Continue (List HashRequest.Request) (StaticHttpRequest.RawRequest FatalError value)
| Finish value
Expand Down
4 changes: 2 additions & 2 deletions src/Pages/Transition.elm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module Pages.Transition exposing
( Transition(..), LoadingState(..), map
( Transition(..), LoadingState(..), map, FormData
, FetcherState, FetcherSubmitStatus(..)
)

{-|
@docs Transition, LoadingState, map
@docs Transition, LoadingState, map, FormData
## Fetchers
Expand Down
5 changes: 2 additions & 3 deletions src/Server/Request.elm
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ import Internal.Request
import Json.Decode
import Json.Encode
import List.NonEmpty
import Pages.Form
import QueryParams
import Time
import Url
Expand Down Expand Up @@ -949,7 +948,7 @@ formData formParsers =
|> andThen
(\rawFormData_ ->
case Form.Handler.run rawFormData_ formParsers of
(Form.Valid decoded) as validated ->
(Form.Valid _) as validated ->
( { persisted =
{ fields = Just rawFormData_
, clientSideErrors = Just Dict.empty
Expand All @@ -960,7 +959,7 @@ formData formParsers =
)
|> succeed

(Form.Invalid maybeDecoded maybeErrors) as validated ->
(Form.Invalid _ maybeErrors) as validated ->
( { persisted =
{ fields = Just rawFormData_
, clientSideErrors = Just maybeErrors
Expand Down
11 changes: 4 additions & 7 deletions src/Stub.elm
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Stub exposing (..)
module Stub exposing (Id, Model, Task(..), map2, nextId)

import Json.Decode as Decode
import Set exposing (Set)
Expand All @@ -24,29 +24,26 @@ type alias Model =

type Task error value
= Pending (Id -> Id) (Decode.Value -> Model -> ( Model, Task error value ))
| Done (Result error value)


map2 : (value1 -> value2 -> combined) -> Task error value1 -> Task error value2 -> Task error combined
map2 mapFn task1 task2 =
case ( task1, task2 ) of
( Done resolved1, Done resolved2 ) ->
Debug.todo ""

( Pending toId1 resolved1, Pending toId2 resolved2 ) ->
( Pending toId1 _, Pending toId2 _ ) ->
Pending
(\id ->
max (toId1 id) (toId2 id)
|> nextId
)
(\value id ->
(\_ _ ->
Debug.todo ""
)

_ ->
Debug.todo ""


nextId : Int -> Int
nextId id =
id + 1

Expand Down
1 change: 0 additions & 1 deletion tests/ApiRouteTests.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module ApiRouteTests exposing (all)
import ApiRoute exposing (..)
import BackendTask
import Expect
import FatalError
import Internal.ApiRoute exposing (tryMatch, withRoutes)
import Pattern exposing (Pattern(..))
import Server.Request
Expand Down
1 change: 0 additions & 1 deletion tests/CookieTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module CookieTest exposing (all)
import CookieParser
import Dict
import Expect
import FatalError
import Test exposing (Test, describe, test)


Expand Down
1 change: 0 additions & 1 deletion tests/FormDataTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ module FormDataTest exposing (all)

import Dict
import Expect
import FatalError
import FormData
import Test exposing (Test, describe, test)

Expand Down
1 change: 0 additions & 1 deletion tests/HeadTests.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module HeadTests exposing (suite)

import Expect
import FatalError
import Head
import Json.Decode
import Test exposing (Test, describe, test)
Expand Down
1 change: 0 additions & 1 deletion tests/Pages/RouteParamsTest.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import Elm.CodeGen
import Elm.Pretty
import Elm.ToString
import Expect exposing (Expectation)
import FatalError
import Fuzz exposing (Fuzzer)
import Pages.Internal.RoutePattern as RoutePattern
import Pretty
Expand Down
Loading

0 comments on commit b01ec4c

Please sign in to comment.