diff --git a/src/Unused/ResponseFilter.hs b/src/Unused/ResponseFilter.hs index d504a40..e2b5f60 100644 --- a/src/Unused/ResponseFilter.hs +++ b/src/Unused/ResponseFilter.hs @@ -47,7 +47,8 @@ autoLowLikelihood l r = classOrModule = classOrModuleFunction . smClassOrModule matchesToBool :: [Matcher] -> Bool - matchesToBool = all (`matcherToBool` r) + matchesToBool [] = False + matchesToBool a = all (`matcherToBool` r) a classOrModuleFunction :: Bool -> TermResults -> Bool classOrModuleFunction True = isClassOrModule diff --git a/test/Unused/ResponseFilterSpec.hs b/test/Unused/ResponseFilterSpec.hs index 1bb8baf..23e3993 100644 --- a/test/Unused/ResponseFilterSpec.hs +++ b/test/Unused/ResponseFilterSpec.hs @@ -128,6 +128,14 @@ spec = parallel $ do haskellAutoLowLikelihood result `shouldReturn` True + describe "autoLowLikelihood" $ + it "doesn't qualify as low when no matchers are present in a language config" $ do + let match = TermMatch "AwesomeThing" "app/foo/awesome_thing.rb" 1 + let result = resultsFromMatches [match] + let languageConfig = LanguageConfiguration "Bad" [] [LowLikelihoodMatch "Match with empty matchers" [] False] [] + + autoLowLikelihood languageConfig result `shouldBe` False + configByName :: String -> IO LanguageConfiguration configByName s = do (Right config) <- loadConfig