From 3b9874756c4786ce0630524f4c673d8aaab16a04 Mon Sep 17 00:00:00 2001 From: Tom Sydney Kerckhove Date: Wed, 8 May 2024 13:59:30 +0200 Subject: [PATCH 1/3] strange refactor --- hints.md | 6 +++--- src/Idea.hs | 12 ++++++++---- src/Summary.hs | 2 +- tests/hint.test | 6 +++--- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/hints.md b/hints.md index da06294ab..811b0ed22 100644 --- a/hints.md +++ b/hints.md @@ -249,7 +249,7 @@ Found:
Suggestion: -Perhaps you should remove it. +You may be able to remove it.
@@ -1050,7 +1050,7 @@ do
Suggestion: -Perhaps you should remove it. +You may be able to remove it.
@@ -1319,7 +1319,7 @@ where
Suggestion: -Perhaps you should remove it. +You may be able to remove it.
Does not support refactoring. diff --git a/src/Idea.hs b/src/Idea.hs index e02673122..95a176b07 100644 --- a/src/Idea.hs +++ b/src/Idea.hs @@ -75,12 +75,16 @@ showIdeaANSI = showEx hsColourConsole showEx :: (String -> String) -> Idea -> String showEx tt Idea{..} = unlines $ [showSrcSpan ideaSpan ++ ": " ++ (if ideaHint == "" then "" else show ideaSeverity ++ ": " ++ ideaHint)] ++ - f "Found" (Just ideaFrom) ++ f "Perhaps" ideaTo ++ + f ideaFrom ++ p ideaTo ++ ["Note: " ++ n | let n = showNotes ideaNote, n /= ""] where - f msg Nothing = [] - f msg (Just x) | null xs = [msg ++ " you should remove it."] - | otherwise = (msg ++ ":") : map (" "++) xs + f x | null xs = ["Found" ++ " you should remove it."] + | otherwise = ("Found" ++ ":") : map (" "++) xs + where xs = lines $ tt x + + p Nothing = [] + p (Just x) | null xs = ["You may be able to remove it."] + | otherwise = ("Perhaps" ++ ":") : map (" "++) xs where xs = lines $ tt x diff --git a/src/Summary.hs b/src/Summary.hs index 21d10dd30..74238cfd7 100644 --- a/src/Summary.hs +++ b/src/Summary.hs @@ -177,7 +177,7 @@ showBuiltin BuiltinHint{..} = row1 where eTo' = case eTo of Nothing -> "" - Just "" -> "Perhaps you should remove it." + Just "" -> "You may be able to remove it." Just s -> s lhsRhsTable :: [HintRule] -> [String] diff --git a/tests/hint.test b/tests/hint.test index 5296bfc55..950f967df 100644 --- a/tests/hint.test +++ b/tests/hint.test @@ -26,7 +26,7 @@ OUTPUT tests/note.hs:1:1-32: Warning: Unused LANGUAGE pragma Found: {-# LANGUAGE RecordWildCards #-} -Perhaps you should remove it. +You may be able to remove it. Note: may require `{-# LANGUAGE DisambiguateRecordFields #-}` adding to the top of the file tests/note.hs:5:11-24: Suggestion: Use null @@ -219,13 +219,13 @@ OUTPUT tests/restricted-extension.hs:1:1-31: Warning: Unused LANGUAGE pragma Found: {-# LANGUAGE DeriveFoldable #-} -Perhaps you should remove it. +You may be able to remove it. Note: Extension DeriveFoldable is implied by DeriveTraversable tests/restricted-extension.hs:2:1-30: Warning: Unused LANGUAGE pragma Found: {-# LANGUAGE DeriveFunctor #-} -Perhaps you should remove it. +You may be able to remove it. Note: Extension DeriveFunctor is implied by DeriveTraversable tests/restricted-extension.hs:2:1-30: Warning: Avoid restricted extensions From b1903affc31873fcb834a60c8ca5efe9e6d8d874 Mon Sep 17 00:00:00 2001 From: Tom Sydney Kerckhove Date: Wed, 8 May 2024 15:58:08 +0200 Subject: [PATCH 2/3] further refactor --- src/Idea.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/Idea.hs b/src/Idea.hs index 95a176b07..2058956d6 100644 --- a/src/Idea.hs +++ b/src/Idea.hs @@ -75,16 +75,13 @@ showIdeaANSI = showEx hsColourConsole showEx :: (String -> String) -> Idea -> String showEx tt Idea{..} = unlines $ [showSrcSpan ideaSpan ++ ": " ++ (if ideaHint == "" then "" else show ideaSeverity ++ ": " ++ ideaHint)] ++ - f ideaFrom ++ p ideaTo ++ + f ideaFrom ++ maybe [] p ideaTo ++ ["Note: " ++ n | let n = showNotes ideaNote, n /= ""] where - f x | null xs = ["Found" ++ " you should remove it."] - | otherwise = ("Found" ++ ":") : map (" "++) xs - where xs = lines $ tt x + f x = ("Found" ++ ":") : map (" "++) (lines (tt x)) - p Nothing = [] - p (Just x) | null xs = ["You may be able to remove it."] - | otherwise = ("Perhaps" ++ ":") : map (" "++) xs + p x | null xs = ["You may be able to remove it."] + | otherwise = ("Perhaps" ++ ":") : map (" "++) xs where xs = lines $ tt x From 42914b386f6753d29c2246acc81bbf1f51ac9542 Mon Sep 17 00:00:00 2001 From: Tom Sydney Kerckhove Date: Wed, 28 Aug 2024 11:11:07 +0200 Subject: [PATCH 3/3] feedback --- hints.md | 6 +++--- src/Idea.hs | 2 +- src/Summary.hs | 2 +- tests/hint.test | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hints.md b/hints.md index 811b0ed22..c84b6dbe8 100644 --- a/hints.md +++ b/hints.md @@ -249,7 +249,7 @@ Found:
Suggestion: -You may be able to remove it. +You can remove it.
@@ -1050,7 +1050,7 @@ do
Suggestion: -You may be able to remove it. +You can remove it.
@@ -1319,7 +1319,7 @@ where
Suggestion: -You may be able to remove it. +You can remove it.
Does not support refactoring. diff --git a/src/Idea.hs b/src/Idea.hs index 2058956d6..d94fb249b 100644 --- a/src/Idea.hs +++ b/src/Idea.hs @@ -80,7 +80,7 @@ showEx tt Idea{..} = unlines $ where f x = ("Found" ++ ":") : map (" "++) (lines (tt x)) - p x | null xs = ["You may be able to remove it."] + p x | null xs = ["You can remove it."] | otherwise = ("Perhaps" ++ ":") : map (" "++) xs where xs = lines $ tt x diff --git a/src/Summary.hs b/src/Summary.hs index 74238cfd7..33ea71864 100644 --- a/src/Summary.hs +++ b/src/Summary.hs @@ -177,7 +177,7 @@ showBuiltin BuiltinHint{..} = row1 where eTo' = case eTo of Nothing -> "" - Just "" -> "You may be able to remove it." + Just "" -> "You can remove it." Just s -> s lhsRhsTable :: [HintRule] -> [String] diff --git a/tests/hint.test b/tests/hint.test index 950f967df..33d64cc6e 100644 --- a/tests/hint.test +++ b/tests/hint.test @@ -26,7 +26,7 @@ OUTPUT tests/note.hs:1:1-32: Warning: Unused LANGUAGE pragma Found: {-# LANGUAGE RecordWildCards #-} -You may be able to remove it. +You can remove it. Note: may require `{-# LANGUAGE DisambiguateRecordFields #-}` adding to the top of the file tests/note.hs:5:11-24: Suggestion: Use null @@ -219,13 +219,13 @@ OUTPUT tests/restricted-extension.hs:1:1-31: Warning: Unused LANGUAGE pragma Found: {-# LANGUAGE DeriveFoldable #-} -You may be able to remove it. +You can remove it. Note: Extension DeriveFoldable is implied by DeriveTraversable tests/restricted-extension.hs:2:1-30: Warning: Unused LANGUAGE pragma Found: {-# LANGUAGE DeriveFunctor #-} -You may be able to remove it. +You can remove it. Note: Extension DeriveFunctor is implied by DeriveTraversable tests/restricted-extension.hs:2:1-30: Warning: Avoid restricted extensions