mirror of
https://github.com/joshuaclayton/unused.git
synced 2024-09-11 12:55:54 +03:00
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:
parent
8a294a6acc
commit
09231cdccd
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user