Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix how Lingo handles ambiguous extensions #592

Open
aymannadeem opened this issue Jul 8, 2020 · 1 comment
Open

Fix how Lingo handles ambiguous extensions #592

aymannadeem opened this issue Jul 8, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@aymannadeem
Copy link
Contributor

Ran into this while working on Rust Tagging. I wasn't able to compile and test because .rs files imply either Rust source of Renderscript. We omit spurious extensions in Source.Language, but instead of a result that returns Unknown -> "Unknown", we should probably throw an exception indicating why this is tripping up (ie., "ambiguous file extension").

for the time being, I added RenderScript for my PR:

forPath :: Path.PartClass.AbsRel ar => Path.File ar -> Language
forPath path =
  let spurious lang = lang `elem` [ "Hack" -- .php files
                                  , "GCC Machine Description" -- .md files
                                  , "XML" -- .tsx files
                                  , "RenderScript" -- .rs files
                                  ]
      allResults = Lingo.languageName <$> Lingo.languagesForPath (Path.toString path)
  in case filter (not . spurious) allResults of
    [result] -> textToLanguage result
    _        -> Unknown
@aymannadeem aymannadeem added the bug Something isn't working label Jul 8, 2020
@patrickt
Copy link
Contributor

forPath should probably return a Maybe Language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants