Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment is repeated. #136

Open
philderbeast opened this issue Jan 20, 2023 · 2 comments
Open

Comment is repeated. #136

philderbeast opened this issue Jan 20, 2023 · 2 comments

Comments

@philderbeast
Copy link

To reproduce, at this revision agda/agda@1fd9e26, edit .hlint.yaml deleting - ignore: {name: "Redundant variable capture"} # 6 hints and then run this refactor:

$ hlint -j --refactor --refactor-options=--inplace src/full/Agda/Compiler/MAlonzo/Compiler.hs

It adds repeats a comment.

@@ -1273,6 +1273,9 @@ writeModule (HS.Module m ps imp ds) = do
                -- project.  (E.g., when using cabal/stack to compile.)
             ]
    liftIO $ UTF8.writeFile out $ (++ "\n") $ prettyPrint $
+    -- TODO: It might make sense to skip bang patterns for the unused
+    -- arguments of the "non-stripped" functions.
   
     -- TODO: It might make sense to skip bang patterns for the unused
     -- arguments of the "non-stripped" functions.
     applyWhen strict makeStrict $
     HS.Module m (concat [languagePragmas, ghcOptions, ps]) imp ds
@pbrisbin
Copy link

pbrisbin commented Dec 18, 2023

I'm running into what I think might be the same issue. Here is a (more) minimal repro:

The file needs something to fix in it (in this case, redundant $) for the refactor to fire.

foo = bar $ baz

instance ToJSON WordStudyQuestionTransitionTypeJSON where
  toJSON
    ( WordStudyQuestionTransitionTypeJSON
        WordStudyQuestionTextAssets {..}
        QuestionJSON {..}
      ) =
      -- We cannot rely on toJSON representations of both because we have overlapping keys: type and content
      -- We want "type" to come from the new question model and "content" to be renamed
      object $
        -- From New Question Model
        [ "id" .= qjId
        , "stemId" .= qjStemId
        , "skillIds" .= qjSkillIds
        , "parentId" .= qjParentId
        , "position" .= qjPosition
        , "worth" .= qjWorth
        , "subject" .= qjSubject
        , "lang" .= qjLang
        , "type" .= qjType
        , -- From Legacy
          "level" .= wordStudyQuestionTextAssetsLevel
        , "contentAudioUrl" .= wordStudyQuestionTextAssetsContentAudioUrl
        , "hasQuestionAudio" .= wordStudyQuestionTextAssetsHasQuestionAudio
        , "diagram" .= wordStudyQuestionTextAssetsDiagram
        , "imageUrl" .= wordStudyQuestionTextAssetsImageUrl
        , "imageDescription" .= wordStudyQuestionTextAssetsImageDescription
        , "wordAudioUrl" .= wordStudyQuestionTextAssetsWordAudioUrl
        , "correctAnswers" .= wordStudyQuestionTextAssetsCorrectAnswers
        , -- Duplicate fields: renaming the new one
          "content" .= wordStudyQuestionTextAssetsContent
        , "content_2" .= qjContent
        ]
          -- From Legacy additional
          <> case wordStudyQuestionTextAssetsAnswers of
            Nothing -> []
            Just answers' -> ["answers" .= answers']
          <> case wordStudyQuestionTextAssetsBucketFieldNames of
            Nothing -> []
            Just bucketFieldNames' -> ["bucketFieldNames" .= bucketFieldNames']

Then run,

hlint --refactor --refactor-options=-i example.hs

And it produces the following diff:

% 1 diff -U 3 example.bak.hs example.hs
--- example.bak.hs	2023-12-18 16:51:39.401224049 -0500
+++ example.hs	2023-12-18 16:50:59.821121001 -0500
@@ -1,4 +1,4 @@
-foo = bar $ baz
+foo = bar baz

 instance ToJSON WordStudyQuestionTransitionTypeJSON where
   toJSON
@@ -10,6 +10,10 @@
       -- We want "type" to come from the new question model and "content" to be renamed
       object $
         -- From New Question Model
+
+        -- From New Question Model
+
+        -- From New Question Model
         [ "id" .= qjId
         , "stemId" .= qjStemId
         , "skillIds" .= qjSkillIds

I'm using the following versions,

% hlint --version
HLint v3.5, (C) Neil Mitchell 2006-2022
% refactor --version
v0.10.0.0%

@vsha96
Copy link

vsha96 commented May 20, 2024

Confirm, that the bug with repeating comments is still happening for

HLint v3.6.1
refactor v0.13.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants