Cover case within autoLowLikelihood where no matches are present

Why?
====

In cases where no matchers are present, a language config should not
auto-classify every match as low-likelihood; instead, it should return
False so subsequent checks can operate on the match itself.

This is related to 9bf9499e67f52bcde2420bfe3945f73cfdaa06d7; both are
handling cases where less configuration data than ideal is present and
the program still needs to operate correctly.
This commit is contained in:
Joshua Clayton 2016-06-07 05:16:25 -04:00
parent 8a294a6acc
commit 09231cdccd
2 changed files with 10 additions and 1 deletions

View File

@ -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

View File

@ -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