Skip to content

Commit bfaeab2

Browse files
author
John Wiegley
committed
Merge remote-tracking branch 'joeyh/nowarnings'
2 parents 890b36f + 65fc36c commit bfaeab2

22 files changed

Lines changed: 103 additions & 106 deletions

Github/Data.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import Control.Monad
1212
import qualified Data.Text as T
1313
import Data.Aeson.Types
1414
import System.Locale (defaultTimeLocale)
15-
import Data.Attoparsec.Number (Number(..))
1615
import qualified Data.Vector as V
1716
import qualified Data.HashMap.Lazy as Map
17+
import Data.Hashable (Hashable)
1818

1919
import Github.Data.Definitions
2020

@@ -394,7 +394,7 @@ instance FromJSON PullRequestLinks where
394394
parseJSON _ = fail "Could not build a PullRequestLinks"
395395

396396
instance FromJSON PullRequestCommit where
397-
parseJSON (Object o) =
397+
parseJSON (Object _) =
398398
return PullRequestCommit
399399
parseJSON _ = fail "Could not build a PullRequestCommit"
400400

@@ -433,6 +433,7 @@ instance FromJSON RepoRef where
433433
parseJSON (Object o) =
434434
RepoRef <$> o .: "owner"
435435
<*> o .: "name"
436+
parseJSON _ = fail "Could not build a RepoRef"
436437

437438
instance FromJSON Contributor where
438439
parseJSON (Object o)
@@ -521,11 +522,13 @@ obj .:< key = case Map.lookup key obj of
521522
Just v -> parseJSON v
522523

523524
-- | Produce all values for the given key.
525+
values :: (Eq k, Hashable k, FromJSON v) => Map.HashMap k Value -> k -> Parser v
524526
obj `values` key =
525527
let (Object children) = findWithDefault (Object Map.empty) key obj in
526528
parseJSON $ Array $ V.fromList $ Map.elems children
527529

528530
-- | Produce the value for the last key by traversing.
531+
(<.:>) :: (FromJSON v) => Object => [T.Text] -> Parser v
529532
obj <.:> [key] = obj .: key
530533
obj <.:> (key:keys) =
531534
let (Object nextObj) = findWithDefault (Object Map.empty) key obj in
@@ -536,6 +539,7 @@ at :: Object -> T.Text -> Maybe Value
536539
obj `at` key = Map.lookup key obj
537540

538541
-- Taken from Data.Map:
542+
findWithDefault :: (Eq k, Hashable k) => v -> k -> Map.HashMap k v -> v
539543
findWithDefault def k m =
540544
case Map.lookup k m of
541545
Nothing -> def

Github/Gists.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ gists = gists' Nothing
2626
--
2727
-- > gist' (Just ("github-username", "github-password")) "225074"
2828
gist' :: Maybe GithubAuth -> String -> IO (Either Error Gist)
29-
gist' auth gistId = githubGet' auth ["gists", gistId]
29+
gist' auth reqGistId = githubGet' auth ["gists", reqGistId]
3030

3131
-- | A specific gist, given its id.
3232
--

Github/Gists/Comments.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import Github.Private
1313
--
1414
-- > commentsOn "1174060"
1515
commentsOn :: String -> IO (Either Error [GistComment])
16-
commentsOn gistId = githubGet ["gists", gistId, "comments"]
16+
commentsOn reqGistId = githubGet ["gists", reqGistId, "comments"]
1717

1818
-- | A specific comment, by the comment ID.
1919
--
2020
-- > comment "62449"
2121
comment :: String -> IO (Either Error GistComment)
22-
comment commentId = githubGet ["gists", "comments", commentId]
22+
comment reqCommentId = githubGet ["gists", "comments", reqCommentId]

Github/GitData/Blobs.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ import Github.Private
1212
--
1313
-- > blob "thoughtbot" "paperclip" "bc5c51d1ece1ee45f94b056a0f5a1674d7e8cba9"
1414
blob :: String -> String -> String -> IO (Either Error Blob)
15-
blob user repoName sha =
16-
githubGet ["repos", user, repoName, "git", "blobs", sha]
15+
blob user reqRepoName sha =
16+
githubGet ["repos", user, reqRepoName, "git", "blobs", sha]

Github/GitData/Commits.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ import Github.Private
1212
--
1313
-- > commit "thoughtbot" "paperclip" "bc5c51d1ece1ee45f94b056a0f5a1674d7e8cba9"
1414
commit :: String -> String -> String -> IO (Either Error GitCommit)
15-
commit user repoName sha =
16-
githubGet ["repos", user, repoName, "git", "commits", sha]
15+
commit user reqRepoName sha =
16+
githubGet ["repos", user, reqRepoName, "git", "commits", sha]

Github/GitData/References.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ import Github.Private
1515
--
1616
-- > reference "mike-burns" "github" "heads/master"
1717
reference :: String -> String -> String -> IO (Either Error GitReference)
18-
reference user repoName ref =
19-
githubGet ["repos", user, repoName, "git", "refs", ref]
18+
reference user reqRepoName ref =
19+
githubGet ["repos", user, reqRepoName, "git", "refs", ref]
2020

2121
-- | The history of references for a repo.
2222
--
2323
-- > references "mike-burns" "github"
2424
references :: String -> String -> IO (Either Error [GitReference])
25-
references user repoName =
26-
githubGet ["repos", user, repoName, "git", "refs"]
25+
references user reqRepoName =
26+
githubGet ["repos", user, reqRepoName, "git", "refs"]
2727

2828
-- | Limited references by a namespace.
2929
--
3030
-- > namespacedReferences "thoughtbot" "paperclip" "tags"
3131
namespacedReferences :: String -> String -> String -> IO (Either Error [GitReference])
32-
namespacedReferences user repoName namespace =
33-
githubGet ["repos", user, repoName, "git", "refs", namespace]
32+
namespacedReferences user reqRepoName namespace =
33+
githubGet ["repos", user, reqRepoName, "git", "refs", namespace]

Github/GitData/Trees.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ import Github.Private
1313
--
1414
-- > tree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844"
1515
tree :: String -> String -> String -> IO (Either Error Tree)
16-
tree user repoName sha =
17-
githubGet ["repos", user, repoName, "git", "trees", sha]
16+
tree user reqRepoName sha =
17+
githubGet ["repos", user, reqRepoName, "git", "trees", sha]
1818

1919
-- | A recursively-nested tree for a SHA1.
2020
--
2121
-- > nestedTree "thoughtbot" "paperclip" "fe114451f7d066d367a1646ca7ac10e689b46844"
2222
nestedTree :: String -> String -> String -> IO (Either Error Tree)
23-
nestedTree user repoName sha =
24-
githubGetWithQueryString ["repos", user, repoName, "git", "trees", sha]
23+
nestedTree user reqRepoName sha =
24+
githubGetWithQueryString ["repos", user, reqRepoName, "git", "trees", sha]
2525
"recursive=1"

Github/Issues.hs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ module Github.Issues (
2121

2222
import Github.Data
2323
import Github.Private
24-
import Data.Aeson.Types
25-
import qualified Data.Aeson as A
2624
import Data.List (intercalate)
2725
import Data.Time.Format (formatTime)
2826
import System.Locale (defaultTimeLocale)
@@ -52,8 +50,8 @@ data IssueLimitation =
5250
--
5351
-- > issue' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" "462"
5452
issue' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error Issue)
55-
issue' auth user repoName issueNumber =
56-
githubGet' auth ["repos", user, repoName, "issues", show issueNumber]
53+
issue' auth user reqRepoName reqIssueNumber =
54+
githubGet' auth ["repos", user, reqRepoName, "issues", show reqIssueNumber]
5755

5856
-- | Details on a specific issue, given the repo owner and name, and the issue
5957
-- number.
@@ -67,10 +65,10 @@ issue = issue' Nothing
6765
--
6866
-- > issuesForRepo' (Just ("github-username", "github-password")) "thoughtbot" "paperclip" [NoMilestone, OnlyClosed, Mentions "jyurek", Ascending]
6967
issuesForRepo' :: Maybe GithubAuth -> String -> String -> [IssueLimitation] -> IO (Either Error [Issue])
70-
issuesForRepo' auth user repoName issueLimitations =
68+
issuesForRepo' auth user reqRepoName issueLimitations =
7169
githubGetWithQueryString'
7270
auth
73-
["repos", user, repoName, "issues"]
71+
["repos", user, reqRepoName, "issues"]
7472
(queryStringFromLimitations issueLimitations)
7573
where
7674
queryStringFromLimitations = intercalate "&" . map convert

Github/Issues/Comments.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,22 @@ import Github.Private
2222
--
2323
-- > comment "thoughtbot" "paperclip" 1468184
2424
comment :: String -> String -> Int -> IO (Either Error IssueComment)
25-
comment user repoName commentId =
26-
githubGet ["repos", user, repoName, "issues", "comments", show commentId]
25+
comment user reqRepoName reqCommentId =
26+
githubGet ["repos", user, reqRepoName, "issues", "comments", show reqCommentId]
2727

2828
-- | All comments on an issue, by the issue's number.
2929
--
3030
-- > comments "thoughtbot" "paperclip" 635
3131
comments :: String -> String -> Int -> IO (Either Error [IssueComment])
32-
comments user repoName issueNumber =
33-
githubGet ["repos", user, repoName, "issues", show issueNumber, "comments"]
32+
comments user reqRepoName reqIssueNumber =
33+
githubGet ["repos", user, reqRepoName, "issues", show reqIssueNumber, "comments"]
3434

3535
-- | All comments on an issue, by the issue's number, using authentication.
3636
--
3737
-- > comments' (GithubUser (user, password)) "thoughtbot" "paperclip" 635
3838
comments' :: Maybe GithubAuth -> String -> String -> Int -> IO (Either Error [IssueComment])
39-
comments' auth user repoName issueNumber =
40-
githubGet' auth ["repos", user, repoName, "issues", show issueNumber, "comments"]
39+
comments' auth user reqRepoName reqIssueNumber =
40+
githubGet' auth ["repos", user, reqRepoName, "issues", show reqIssueNumber, "comments"]
4141

4242

4343

Github/Issues/Events.hs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ import Github.Private
1414
--
1515
-- > eventsForIssue "thoughtbot" "paperclip" 49
1616
eventsForIssue :: String -> String -> Int -> IO (Either Error [Event])
17-
eventsForIssue user repoName issueNumber =
18-
githubGet ["repos", user, repoName, "issues", show issueNumber, "events"]
17+
eventsForIssue user reqRepoName reqIssueNumber =
18+
githubGet ["repos", user, reqRepoName, "issues", show reqIssueNumber, "events"]
1919

2020
-- | All the events for all issues in a repo.
2121
--
2222
-- > eventsForRepo "thoughtbot" "paperclip"
2323
eventsForRepo :: String -> String -> IO (Either Error [Event])
24-
eventsForRepo user repoName =
25-
githubGet ["repos", user, repoName, "issues", "events"]
24+
eventsForRepo user reqRepoName =
25+
githubGet ["repos", user, reqRepoName, "issues", "events"]
2626

2727
-- | Details on a specific event, by the event's ID.
2828
--
2929
-- > event "thoughtbot" "paperclip" 5335772
3030
event :: String -> String -> Int -> IO (Either Error Event)
31-
event user repoName eventId =
32-
githubGet ["repos", user, repoName, "issues", "events", show eventId]
31+
event user reqRepoName reqEventId =
32+
githubGet ["repos", user, reqRepoName, "issues", "events", show reqEventId]

0 commit comments

Comments
 (0)