packages feed

homplexity 0.4.2.0 → 0.4.3.0

raw patch · 9 files changed

+72/−14 lines, 9 files

Files

Language/Haskell/Homplexity/Assessment.hs view
@@ -11,7 +11,8 @@ -- | Main module parsing inputs, and running analysis. module Language.Haskell.Homplexity.Assessment (     metrics-  , measureAllOccurs) where+  --, measureAllOccurs+  ) where  import Data.Data import Data.Monoid@@ -46,9 +47,18 @@ measureTopOccurs assess = measureAll assess occurs  --measureAllOccurs  :: (CodeFragment c, Metric m c) => Severity -> Proxy m -> Proxy c -> Program -> Log+-- | Measure all occurences of a given @CodeFragment@ with a given @Metric@,+-- then use @Assessment@ on them and give a list of @Log@ messages.+--+-- Arguments come in the following order:+-- 1. @Assessment@ for the value of the @Metric@.+-- 2. @Metric@ given as @Proxy@ type.+-- 3. @CodeFragment@ given as @Proxy@ type.+-- 4. Program containing @CodeFragment@s. measureAllOccurs :: (Data from, Metric m c) => Assessment m -> Proxy m -> Proxy c -> from -> Log measureAllOccurs assess = measureAll assess allOccurs +-- | Type of functions that convert a @Metric@ into a log message. type Assessment m = m -> (Severity, String)  warnOfMeasure :: (CodeFragment c, Metric m c) => Assessment m -> Proxy m -> Proxy c -> c -> Log
Language/Haskell/Homplexity/CodeFragment.hs view
@@ -98,6 +98,7 @@   fragmentSlice ::     c -> SrcSlice   fragmentSlice  = srcSlice +-- | First location for each @CodeFragment@ - for convenient reporting. fragmentLoc :: (CodeFragment c) => c -> SrcLoc fragmentLoc =  getPointLoc             .  fragmentSlice
Language/Haskell/Homplexity/Comments.hs view
@@ -51,13 +51,6 @@   Just '*' -> CommentsInside -- since it comments out the group of declarations, it belongs to the containing object   _        -> CommentsInside --- * Tests for comments-prop_commentsAfter, prop_commentsBefore, prop_commentsGroup, prop_commentsInside :: Bool-prop_commentsAfter  = findCommentType "  |" == CommentsAfter-prop_commentsBefore = findCommentType "  ^" == CommentsBefore-prop_commentsGroup  = findCommentType "  *" == CommentsInside-prop_commentsInside = findCommentType "  a" == CommentsInside- -- * Finding ranges of all commentable entities. -- | Tagging of source range for each commentable object. data CommentSite = CommentSite { siteName  :: String
Language/Haskell/Homplexity/Message.hs view
@@ -2,6 +2,7 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE RecordWildCards            #-} {-# LANGUAGE TemplateHaskell            #-}+-- | Classifying messages by severity and filtering them. module Language.Haskell.Homplexity.Message (     Log   , Message
Language/Haskell/Homplexity/Metric.hs view
@@ -1,7 +1,8 @@ {-# LANGUAGE FlexibleInstances     #-}-{-# LANGUAGE MultiParamTypeClasses #-}-{-# LANGUAGE ScopedTypeVariables   #-}+{-# LANGUAGE MultiParamTypeClasses      #-}+{-# LANGUAGE ScopedTypeVariables        #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-}+-- | Class for defining code metrics, and its simplest implementation - number of lines of code.  module Language.Haskell.Homplexity.Metric (     Metric (..)   , LOC@@ -19,7 +20,6 @@ import Language.Haskell.Exts.Syntax  import Language.Haskell.Homplexity.CodeFragment-  -- | Metric can be computed on a set of @CodeFragment@ fragments -- and then shown.
Language/Haskell/Homplexity/TypeComplexity.hs view
@@ -39,7 +39,7 @@  -- | Function computing constructor depth of a @Type@. conDepth :: Type -> Int-conDepth con = deeper con + maxOf conDepth (childrenBi con)+conDepth con = deeper con + maxOf conDepth (filter (/= con) $ childrenBi con)  -- | Check whether given constructor of @Type@ counts in constructor depth computation. deeper :: Type -> Int
changelog.md view
@@ -1,5 +1,9 @@ Changelog =========+    0.4.3.0  Jun 2015++        * Thanks to Mikolaj Konarski for fixing an embarrassing eternal loop due to biplate quirk.+     0.4.2.0  Jun 2015          * Compatible with GHC 7.8.
homplexity.cabal view
@@ -1,5 +1,5 @@ name:                homplexity-version:             0.4.2.0+version:             0.4.3.0 synopsis:            Haskell code quality tool description:         Homplexity aims to measure code complexity,                      warning about fragments that might have higher defect probability@@ -22,7 +22,7 @@ extra-source-files:  README.md changelog.md cabal-version:       >=1.10 bug-reports:         https://github.com/mgajda/homplexity/issues-tested-with:         GHC==7.10.1+tested-with:         GHC==7.10.1,GHC==7.8.4  source-repository head   type:     git@@ -69,4 +69,15 @@   build-tools:         happy            >= 1.19.0   -- hs-source-dirs:         default-language:    Haskell2010++test-suite Comments+  main-is:          tests/Comments.hs+  other-modules:    Language.Haskell.Homplexity.CodeFragment+                    Language.Haskell.Homplexity.Comments+                    Language.Haskell.Homplexity.SrcSlice+  type:             exitcode-stdio-1.0+  build-depends:    base             >=4.5  && <4.9,+                    haskell-src-exts >=1.12 && <1.17,+                    uniplate         >=1.4  && <1.7+  default-language: Haskell2010 
+ tests/Comments.hs view
@@ -0,0 +1,38 @@+{-# LANGUAGE FlexibleContexts      #-}+{-# LANGUAGE FlexibleInstances     #-}+{-# LANGUAGE MultiParamTypeClasses #-}+{-# LANGUAGE ScopedTypeVariables   #-}+{-# LANGUAGE UndecidableInstances  #-}+module Main (+    main +  ) where++import Data.Char+import Data.List+import Control.Exception as E++import Language.Haskell.Exts.SrcLoc+import Language.Haskell.Exts++import Language.Haskell.Homplexity.Comments++-- * Tests for comments+prop_commentsAfter ::  Bool+prop_commentsAfter  = findCommentType "  |" == CommentsAfter++prop_commentsBefore ::  Bool+prop_commentsBefore = findCommentType "  ^" == CommentsBefore++prop_commentsGroup ::  Bool+prop_commentsGroup  = findCommentType "  *" == CommentsInside++prop_commentsInside ::  Bool+prop_commentsInside = findCommentType "  a" == CommentsInside++-- Runs all unit tests.+main :: IO ()+main  = assert (and [prop_commentsAfter+                    ,prop_commentsBefore+                    ,prop_commentsGroup+                    ,prop_commentsInside]) $+          return ()