Skip to content

Commit 27fcba4

Browse files
committed
Code review comments
1 parent d4f027f commit 27fcba4

File tree

8 files changed

+50
-34
lines changed

8 files changed

+50
-34
lines changed

Diff for: .dockerignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
dist/
44

55
cc/*
6-
!cc/engine.hs
6+
!cc/*.cabal
7+
!cc/*.hs

Diff for: cc/Dockerfile

+13-5
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,25 @@ ENV PATH /root/.local/bin:$PATH
1010
RUN mkdir -p /src
1111
WORKDIR /src
1212

13+
# Install appropriate GHC
1314
COPY stack.yaml /src/
1415
RUN stack setup
1516

17+
# Install HLint
1618
COPY hlint.cabal /src/
1719
RUN stack install --dependencies-only
18-
1920
COPY ./src /src/src
2021
COPY ./data /src/data
21-
COPY ./cc/engine.hs /src/cc/engine.hs
2222
COPY ./LICENSE /src/LICENSE
23-
RUN stack install --flag hlint:cc
23+
RUN stack install
24+
25+
# Install CC/Engine executable
26+
RUN mkdir -p /cc
27+
WORKDIR /cc
28+
COPY ./cc/engine.cabal /cc/engine.cabal
29+
RUN stack init && stack install --dependencies-only
30+
COPY ./cc/Engine.hs /cc/Engine.hs
31+
RUN stack install
2432

2533
#
2634
# Runtime
@@ -32,8 +40,8 @@ ENV LANG en_US.UTF-8
3240

3341
# Executables from build stage
3442
COPY --from=builder /root/.local/bin/hlint /usr/bin/hlint
35-
COPY --from=builder /root/.local/bin/cc-engine /usr/bin/engine
36-
COPY data /opt/hlint
43+
COPY --from=builder /root/.local/bin/engine /usr/bin/engine
44+
COPY --from=builder /src/data /opt/hlint
3745

3846
RUN mkdir -p /code
3947
VOLUME /code

Diff for: cc/engine.hs renamed to cc/Engine.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-# LANGUAGE OverloadedStrings #-}
2-
module Main where
2+
module Main (main) where
33

44
import Data.Aeson
55
import Data.List (isSuffixOf)
@@ -64,8 +64,8 @@ main = do
6464

6565
callProcess "hlint" $
6666
[ "lint"
67+
, "--cc"
6768
, "--datadir", "/opt/hlint"
68-
, "--json-cc"
6969
, "--no-exit-code"
7070
]
7171
++ cExtraFlags c

Diff for: cc/engine.cabal

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
cabal-version: >= 1.18
2+
build-type: Simple
3+
name: engine
4+
version: 0.0.1
5+
category: Development
6+
author: Patrick Brisbin <[email protected]>
7+
maintainer: Patrick Brisbin <[email protected]>
8+
copyright: Neil Mitchell 2006-2017
9+
synopsis: Run HLint as a Code Climate engine
10+
description: Run HLint as a Code Climate engine
11+
homepage: https://github.com/ndmitchell/hlint#readme
12+
bug-reports: https://github.com/ndmitchell/hlint/issues
13+
14+
executable engine
15+
default-language: Haskell2010
16+
build-depends: base
17+
, aeson
18+
, bytestring
19+
, process
20+
main-is: Engine.hs
21+
ghc-options: -rtsopts -threaded

Diff for: hlint.cabal

-21
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ flag gpl
4343
manual: True
4444
description: Use GPL libraries, specifically hscolour
4545

46-
flag cc
47-
default: False
48-
manual: True
49-
description: Build the Code Climate engine executable
50-
5146
library
5247
default-language: Haskell2010
5348
build-depends:
@@ -133,19 +128,3 @@ executable hlint
133128
ghc-options: -rtsopts
134129
if flag(threaded)
135130
ghc-options: -threaded
136-
137-
executable cc-engine
138-
if !flag(cc)
139-
buildable: False
140-
141-
default-language: Haskell2010
142-
build-depends: base
143-
, aeson
144-
, bytestring
145-
, process
146-
main-is: engine.hs
147-
hs-source-dirs: cc
148-
149-
ghc-options: -rtsopts
150-
if flag(threaded)
151-
ghc-options: -threaded

Diff for: src/CC.hs

+9-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ data Issue = Issue
2525
{ issueType :: Text
2626
, issueCheckName :: Text
2727
, issueDescription :: Text
28-
, issueContent :: Text -- TODO: Markdown type?
28+
, issueContent :: Text
2929
, issueCategories :: [Text]
3030
, issueLocation :: Location
3131
, issueRemediationPoints :: Int
@@ -75,7 +75,7 @@ fromIdea Idea{..} = Issue
7575
{ issueType = "issue"
7676
, issueCheckName = "HLint/" <> T.pack (camelize ideaHint)
7777
, issueDescription = T.pack ideaHint
78-
, issueContent = content ideaFrom ideaTo
78+
, issueContent = content ideaFrom ideaTo <> listNotes ideaNote
7979
, issueCategories = categories ideaHint
8080
, issueLocation = fromSrcSpan ideaSpan
8181
, issueRemediationPoints = points ideaSeverity
@@ -106,6 +106,13 @@ fromIdea Idea{..} = Issue
106106
, "```"
107107
]
108108

109+
listNotes [] = ""
110+
listNotes notes = T.unlines $
111+
[ ""
112+
, "Applying this change:"
113+
, ""
114+
] ++ map (("* " <>) . T.pack . show) notes
115+
109116
categories _ = ["Style"]
110117

111118
points Ignore = 0

Diff for: src/CmdLine.hs

+2-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ data Cmd
114114
,cmdCppSimple :: Bool
115115
,cmdCppAnsi :: Bool
116116
,cmdJson :: Bool -- ^ display hint data as JSON
117-
,cmdJsonCC :: Bool -- ^ display hint data as Code Climate Issues
117+
,cmdCC :: Bool -- ^ display hint data as Code Climate Issues
118118
,cmdNoSummary :: Bool -- ^ do not show the summary info
119119
,cmdOnly :: [String] -- ^ specify which hints explicitly
120120
,cmdNoExitCode :: Bool
@@ -175,7 +175,7 @@ mode = cmdArgsMode $ modes
175175
,cmdCppSimple = nam_ "cpp-simple" &= help "Use a simple CPP (strip # lines)"
176176
,cmdCppAnsi = nam_ "cpp-ansi" &= help "Use CPP in ANSI compatibility mode"
177177
,cmdJson = nam_ "json" &= help "Display hint data as JSON"
178-
,cmdJsonCC = nam_ "json-cc" &= help "Display hint data as Code Climate Issues JSON"
178+
,cmdCC = nam_ "cc" &= help "Display hint data as Code Climate Issues"
179179
,cmdNoSummary = nam_ "no-summary" &= help "Do not show summary information"
180180
,cmdOnly = nam "only" &= typ "HINT" &= help "Specify which hints explicitly"
181181
,cmdNoExitCode = nam_ "no-exit-code" &= help "Do not give a negative exit if hints"

Diff for: src/HLint.hs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ runHints args settings cmd@CmdMain{..} = do
160160
ideas <- return $ if cmdShowAll then ideas else filter (\i -> ideaSeverity i /= Ignore) ideas
161161
if cmdJson then
162162
putStrLn $ showIdeasJson ideas
163-
else if cmdJsonCC then
163+
else if cmdCC then
164164
mapM_ (printIssue . fromIdea) ideas
165165
else if cmdSerialise then do
166166
hSetBuffering stdout NoBuffering

0 commit comments

Comments
 (0)