From 04081dbdac1233848cfc4558cde8975333721d98 Mon Sep 17 00:00:00 2001 From: Jeroen Engels Date: Sat, 8 Apr 2023 21:55:27 +0200 Subject: [PATCH] Extract to variable --- src/Review/Project/Valid.elm | 50 ++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/src/Review/Project/Valid.elm b/src/Review/Project/Valid.elm index c819331b..bf7df0c9 100644 --- a/src/Review/Project/Valid.elm +++ b/src/Review/Project/Valid.elm @@ -510,31 +510,37 @@ addElmJson elmJson_ (ValidProject project) = if sourceDirectories /= Review.Project.Internal.sourceDirectoriesForProject previousElmJson then Nothing - else if areDependenciesUnchanged { before = previousElmJson, after = elmJson_.project } then - -- Dependencies are unchanged - ValidProject { project | elmJson = Just ( elmJson_, ContentHash.hash elmJson_.raw ) } - |> Just - else let - newDependencies : Dict String Dependency - newDependencies = - -- TODO Remove from `dependencies` if some have been removed or their version has changed - -- and return `Nothing` if some have been added - project.dependencies - - directDependencies_ : Dict String Dependency - directDependencies_ = - computeDirectDependencies { elmJson = Just ( elmJson_, ContentHash.hash elmJson_.raw ), dependencies = newDependencies } + elmJsonData : ( { path : String, raw : String, project : Elm.Project.Project }, ContentHash ) + elmJsonData = + ( elmJson_, ContentHash.hash elmJson_.raw ) in - ValidProject - { project - | elmJson = Just ( elmJson_, ContentHash.hash elmJson_.raw ) - , dependencies = newDependencies - , directDependencies = directDependencies_ - , dependencyModules = computeDependencyModules directDependencies_ - } - |> Just + if areDependenciesUnchanged { before = previousElmJson, after = elmJson_.project } then + -- Dependencies are unchanged + ValidProject { project | elmJson = Just elmJsonData } + |> Just + + else + let + newDependencies : Dict String Dependency + newDependencies = + -- TODO Remove from `dependencies` if some have been removed or their version has changed + -- and return `Nothing` if some have been added + project.dependencies + + directDependencies_ : Dict String Dependency + directDependencies_ = + computeDirectDependencies { elmJson = Just elmJsonData, dependencies = newDependencies } + in + ValidProject + { project + | elmJson = Just elmJsonData + , dependencies = newDependencies + , directDependencies = directDependencies_ + , dependencyModules = computeDependencyModules directDependencies_ + } + |> Just areDependenciesUnchanged : { before : Elm.Project.Project, after : Elm.Project.Project } -> Bool