Fix naming and pattern-matching

This commit is contained in:
Joshua Clayton 2016-07-19 16:22:54 -04:00
parent 7fe32edc4d
commit 060f1e3499
No known key found for this signature in database
GPG Key ID: 5B6558F77E9A8118

View File

@ -98,11 +98,11 @@ tmDisplayTerm :: TermMatch -> String
tmDisplayTerm = liftM2 M.fromMaybe tmTerm tmAlias tmDisplayTerm = liftM2 M.fromMaybe tmTerm tmAlias
resultsFromMatches :: [TermMatch] -> TermResults resultsFromMatches :: [TermMatch] -> TermResults
resultsFromMatches m = resultsFromMatches tms =
TermResults TermResults
{ trTerm = resultTerm terms { trTerm = resultTerm terms
, trTerms = L.sort $ L.nub terms , trTerms = L.sort $ L.nub terms
, trMatches = m , trMatches = tms
, trAppOccurrences = appOccurrence , trAppOccurrences = appOccurrence
, trTestOccurrences = testOccurrence , trTestOccurrences = testOccurrence
, trTotalOccurrences = Occurrences (sum $ map oFiles [appOccurrence, testOccurrence]) (sum $ map oOccurrences [appOccurrence, testOccurrence]) , trTotalOccurrences = Occurrences (sum $ map oFiles [appOccurrence, testOccurrence]) (sum $ map oOccurrences [appOccurrence, testOccurrence])
@ -110,9 +110,9 @@ resultsFromMatches m =
, trGitContext = Nothing , trGitContext = Nothing
} }
where where
testOccurrence = testOccurrences m testOccurrence = testOccurrences tms
appOccurrence = appOccurrences m appOccurrence = appOccurrences tms
terms = map tmDisplayTerm m terms = map tmDisplayTerm tms
resultTerm (x:_) = x resultTerm (x:_) = x
resultTerm _ = "" resultTerm _ = ""
@ -144,7 +144,5 @@ testCamelCaseFilename :: String -> Bool
testCamelCaseFilename = R.matchRegex ".*(Spec|Test)\\." testCamelCaseFilename = R.matchRegex ".*(Spec|Test)\\."
termMatchIsTest :: TermMatch -> Bool termMatchIsTest :: TermMatch -> Bool
termMatchIsTest m = termMatchIsTest TermMatch{tmPath = path} =
testDir path || testSnakeCaseFilename path || testCamelCaseFilename path testDir path || testSnakeCaseFilename path || testCamelCaseFilename path
where
path = tmPath m