rubik / argon

Monitor cyclomatic complexity in Haskell programs
BSD 3-Clause "New" or "Revised" License
97 stars 8 forks source link

Extensions from the cabal file are not picked up #25

Open mohsen3 opened 8 years ago

mohsen3 commented 8 years ago

I have a project in which I specified a few commonly used ghc extensions inside the cabal file. It seems to me that argon does not pickup the extensions from the cabal file, since I am getting a lot of errors. If I put the extension at the top of the module {-# LANGUAGE BangPatterns #-} it works fine.

mohsen3 commented 8 years ago

It seems that the problem comes from the extFromBI function in the Argon.Cabal module. It only looks at defaultExtensions, while the extensions in my cabal file are listed (for reasons that I don't understand) under the oldExtensions. I fixed the issue by adding the oldExtensions and otherExtensions to the list. I can make a pull request if you like.

rubik commented 8 years ago

I looked into this when I first added the feature. But from Cabal's documentation it wasn't entirely clear what was oldExtensions for. Since in your case it only works with that change, feel free to open a PR!

mohsen3 commented 8 years ago

I made a PR that considers the otherExtensions and oldExtensions for the library section of the cabal file. Why don't you consider the extensions in the executable, test, and benchmark sections?

rubik commented 8 years ago

Thanks! I don't want to pull in all the other extensions because they could not be relevant and could break the parsing. It's probably better to add a CLI option to specify add custom extensions, just like -X does with GHC.

mohsen3 commented 8 years ago

I totally agree that the -X option is a helpful one. I think the correct way to handle cabal files is to parse the source folder path as well as the extensions for each target and use the per target extension list instead. That's what cabal does. Are you using the cabal files for anything other than finding the extension list? It is not clear from the documentation of the command line options, I think.

rubik commented 8 years ago

Good suggestion. Currently, Argon just reads the extensions from the cabal file. I'll open two new issues for these features.