2022-02-13 23:42:31 +03:00
|
|
|
module Pages.Review.DeadCodeEliminateDataTest exposing (all)
|
|
|
|
|
|
|
|
import Pages.Review.DeadCodeEliminateData exposing (rule)
|
|
|
|
import Review.Test
|
|
|
|
import Test exposing (Test, describe, test)
|
|
|
|
|
|
|
|
|
|
|
|
all : Test
|
|
|
|
all =
|
2022-02-27 01:10:31 +03:00
|
|
|
describe "dead code elimination"
|
2022-02-13 23:42:31 +03:00
|
|
|
[ test "replaces data record setter" <|
|
|
|
|
\() ->
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
import DataSource exposing (DataSource)
|
2022-03-11 22:29:57 +03:00
|
|
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
2022-02-13 23:42:31 +03:00
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Pages.Url
|
|
|
|
import Path
|
|
|
|
import Route exposing (Route)
|
|
|
|
import Shared
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
2022-03-11 22:29:57 +03:00
|
|
|
single
|
2022-02-13 23:42:31 +03:00
|
|
|
{ head = head
|
|
|
|
, data = data
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
data : DataSource Data
|
|
|
|
data =
|
|
|
|
DataSource.succeed ()
|
|
|
|
"""
|
|
|
|
|> Review.Test.run rule
|
|
|
|
|> Review.Test.expectErrors
|
|
|
|
[ Review.Test.error
|
|
|
|
{ message = "Codemod"
|
|
|
|
, details =
|
|
|
|
[ "" ]
|
|
|
|
, under =
|
|
|
|
"""data = data
|
|
|
|
}"""
|
|
|
|
}
|
|
|
|
|> Review.Test.whenFixed
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
import DataSource exposing (DataSource)
|
2022-03-11 22:29:57 +03:00
|
|
|
import RouteBuilder exposing (Page, StaticPayload, single)
|
2022-02-13 23:42:31 +03:00
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Pages.Url
|
|
|
|
import Path
|
|
|
|
import Route exposing (Route)
|
|
|
|
import Shared
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
2022-03-11 22:29:57 +03:00
|
|
|
single
|
2022-02-13 23:42:31 +03:00
|
|
|
{ head = head
|
|
|
|
, data = DataSource.fail ""
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
data : DataSource Data
|
|
|
|
data =
|
|
|
|
DataSource.succeed ()
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
, test "replaces data record setter with non-empty RouteParams" <|
|
|
|
|
\() ->
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Blog.Slug_ exposing (Data, Model, Msg, route)
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
import DataSource exposing (DataSource)
|
2022-03-05 20:50:01 +03:00
|
|
|
import RouteBuilder exposing (Page, StaticPayload)
|
2022-02-13 23:42:31 +03:00
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Pages.Url
|
|
|
|
import Path
|
|
|
|
import Route exposing (Route)
|
|
|
|
import Shared
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{ slug : String }
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
|
|
|
RouteBuilder.preRender
|
2022-02-13 23:42:31 +03:00
|
|
|
{ data = data
|
|
|
|
, head = head
|
|
|
|
, pages = pages
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
data : DataSource Data
|
|
|
|
data =
|
|
|
|
DataSource.succeed ()
|
|
|
|
"""
|
|
|
|
|> Review.Test.run rule
|
|
|
|
|> Review.Test.expectErrors
|
|
|
|
[ Review.Test.error
|
|
|
|
{ message = "Codemod"
|
|
|
|
, details =
|
|
|
|
[ "" ]
|
|
|
|
, under =
|
|
|
|
"""data = data"""
|
|
|
|
}
|
|
|
|
|> Review.Test.whenFixed
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Blog.Slug_ exposing (Data, Model, Msg, route)
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
import DataSource exposing (DataSource)
|
2022-03-05 20:50:01 +03:00
|
|
|
import RouteBuilder exposing (Page, StaticPayload)
|
2022-02-13 23:42:31 +03:00
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Pages.Url
|
|
|
|
import Path
|
|
|
|
import Route exposing (Route)
|
|
|
|
import Shared
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{ slug : String }
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
|
|
|
RouteBuilder.preRender
|
2022-02-13 23:42:31 +03:00
|
|
|
{ data = \\_ -> DataSource.fail ""
|
|
|
|
, head = head
|
|
|
|
, pages = pages
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
data : DataSource Data
|
|
|
|
data =
|
|
|
|
DataSource.succeed ()
|
2022-02-14 00:52:31 +03:00
|
|
|
"""
|
|
|
|
]
|
2022-03-05 20:50:01 +03:00
|
|
|
, test "replaces data record setter with RouteBuilder.serverRendered" <|
|
2022-02-14 00:52:31 +03:00
|
|
|
\() ->
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
2022-02-14 00:52:31 +03:00
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
2022-03-05 20:50:01 +03:00
|
|
|
RouteBuilder.serverRender
|
2022-02-14 00:52:31 +03:00
|
|
|
{ head = head
|
|
|
|
, data = data
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-14 00:52:31 +03:00
|
|
|
"""
|
|
|
|
|> Review.Test.run rule
|
|
|
|
|> Review.Test.expectErrors
|
|
|
|
[ Review.Test.error
|
|
|
|
{ message = "Codemod"
|
|
|
|
, details =
|
|
|
|
[ "" ]
|
|
|
|
, under =
|
|
|
|
"""data = data
|
|
|
|
}"""
|
|
|
|
}
|
|
|
|
|> Review.Test.whenFixed
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
2022-02-14 00:52:31 +03:00
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
2022-03-05 20:50:01 +03:00
|
|
|
RouteBuilder.serverRender
|
2022-02-14 00:52:31 +03:00
|
|
|
{ head = head
|
|
|
|
, data = \\_ -> Request.oneOf []
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-13 23:42:31 +03:00
|
|
|
"""
|
|
|
|
]
|
2022-02-22 02:50:17 +03:00
|
|
|
, test "no Request.oneOf fix after replacement is made" <|
|
|
|
|
\() ->
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Login exposing (Data, Model, Msg, route)
|
2022-02-22 02:50:17 +03:00
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
2022-03-05 20:50:01 +03:00
|
|
|
RouteBuilder.serverRender
|
2022-02-22 02:50:17 +03:00
|
|
|
{ head = head
|
|
|
|
, data = \\_ -> Request.oneOf []
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-22 02:50:17 +03:00
|
|
|
"""
|
|
|
|
|> Review.Test.run rule
|
|
|
|
|> Review.Test.expectNoErrors
|
2022-02-13 23:42:31 +03:00
|
|
|
, test "no fix after replacement is made" <|
|
|
|
|
\() ->
|
2022-03-09 20:48:48 +03:00
|
|
|
"""module Route.Index exposing (Data, Model, Msg, route)
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
import DataSource exposing (DataSource)
|
2022-03-05 20:50:01 +03:00
|
|
|
import RouteBuilder exposing (Page, StaticPayload)
|
2022-02-13 23:42:31 +03:00
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Pages.Url
|
|
|
|
import Path
|
|
|
|
import Route exposing (Route)
|
|
|
|
import Shared
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Msg =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type alias RouteParams =
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
2022-06-29 01:45:36 +03:00
|
|
|
route : StatelessRoute RouteParams Data ActionData
|
2022-03-09 20:48:48 +03:00
|
|
|
route =
|
2022-03-05 20:50:01 +03:00
|
|
|
RouteBuilder.single
|
2022-02-13 23:42:31 +03:00
|
|
|
{ head = head
|
|
|
|
, data = DataSource.fail ""
|
|
|
|
}
|
2022-03-05 20:50:01 +03:00
|
|
|
|> RouteBuilder.buildNoState { view = view }
|
2022-02-13 23:42:31 +03:00
|
|
|
|
|
|
|
|
|
|
|
data : DataSource Data
|
|
|
|
data =
|
|
|
|
DataSource.succeed ()
|
|
|
|
"""
|
|
|
|
|> Review.Test.run rule
|
|
|
|
|> Review.Test.expectNoErrors
|
|
|
|
, test "replaces data record setter in Shared module" <|
|
|
|
|
\() ->
|
|
|
|
"""module Shared exposing (Data, Model, Msg, template)
|
|
|
|
|
|
|
|
import Browser.Navigation
|
|
|
|
import DataSource
|
|
|
|
import Html exposing (Html)
|
|
|
|
import Html.Styled
|
|
|
|
import Pages.Flags
|
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Path exposing (Path)
|
|
|
|
import Route exposing (Route)
|
|
|
|
import SharedTemplate exposing (SharedTemplate)
|
|
|
|
import TableOfContents
|
|
|
|
import View exposing (View)
|
|
|
|
import View.Header
|
|
|
|
|
|
|
|
|
|
|
|
template : SharedTemplate Msg Model Data msg
|
|
|
|
template =
|
|
|
|
{ init = init
|
|
|
|
, update = update
|
|
|
|
, view = view
|
|
|
|
, data = data
|
|
|
|
, subscriptions = subscriptions
|
|
|
|
, onPageChange = Just OnPageChange
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
TableOfContents.TableOfContents TableOfContents.Data
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{ showMobileMenu : Bool
|
|
|
|
, counter : Int
|
|
|
|
, navigationKey : Maybe Browser.Navigation.Key
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
|> Review.Test.run rule
|
|
|
|
|> Review.Test.expectErrors
|
|
|
|
[ Review.Test.error
|
|
|
|
{ message = "Codemod"
|
|
|
|
, details =
|
|
|
|
[ "" ]
|
|
|
|
, under =
|
|
|
|
"""data = data
|
|
|
|
,"""
|
|
|
|
}
|
|
|
|
|> Review.Test.whenFixed
|
|
|
|
"""module Shared exposing (Data, Model, Msg, template)
|
|
|
|
|
|
|
|
import Browser.Navigation
|
|
|
|
import DataSource
|
|
|
|
import Html exposing (Html)
|
|
|
|
import Html.Styled
|
|
|
|
import Pages.Flags
|
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Path exposing (Path)
|
|
|
|
import Route exposing (Route)
|
|
|
|
import SharedTemplate exposing (SharedTemplate)
|
|
|
|
import TableOfContents
|
|
|
|
import View exposing (View)
|
|
|
|
import View.Header
|
|
|
|
|
|
|
|
|
|
|
|
template : SharedTemplate Msg Model Data msg
|
|
|
|
template =
|
|
|
|
{ init = init
|
|
|
|
, update = update
|
|
|
|
, view = view
|
|
|
|
, data = DataSource.fail ""
|
|
|
|
, subscriptions = subscriptions
|
|
|
|
, onPageChange = Just OnPageChange
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
TableOfContents.TableOfContents TableOfContents.Data
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{ showMobileMenu : Bool
|
|
|
|
, counter : Int
|
|
|
|
, navigationKey : Maybe Browser.Navigation.Key
|
|
|
|
}
|
|
|
|
"""
|
|
|
|
]
|
|
|
|
]
|