-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor data collection. #71
Conversation
beef978
to
365e9d6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great PR description! but so dirty commit history..
Can you do something with it? It's become really hard to review your changes.
- Go through your commits and decide which small steps to your final result this commits lead you.
- Add description for each commit (as described in our policy) so we can review this steps separately and understand it.
- Use
git commit --fixup HASH
to fix smth in your previous commits, so we can understand to which commits related your fixes.
, "\"" <> txt <> "\"" | ||
, "perhaps you meant \ | ||
\<\"ignore link\"|\"ignore paragraph\"|\"ignore file\"> " | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is not a good thing actually. Putting error messages far from the use site, we encourage their divergence from the actual problem (e.g. the actual error can obtain one more condition when it fires, but it is now easy to forget to update the error message respectively).
I think error messages and where they are used should both fit into one screen, maybe put in where
/letl
block if found to make the code less readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My opinion, per change:
- Using post-imports - kaef (though I wonder, didn't @worm2fed implemented this already somewhere else, taking Add requirement for qualified imports style#11 into account?)
1.5. Mixins removal - good;import Universum
addition - ok. - Using
polysemy
- I would retract from doing this change until it actually appears necessary, because using it makes things more complex for newcomers, and there might be cases not well supported by it (as with any advanced framework). - Using the Visitor pattern - the same thing, the current Markdown scanner already does most of the things we ever want from it and it just works. After the rewrite, we use only
inside
event, so things just got more complex without immediate benefit. And it's not clear whether future changes in the scanner logic, if any, will fit into the current model without increasing its complexity in directions other than that you support now. - Error messages extraction to a separate module - responded in another comment. The fact of extraction is good, but error message and condition for it to fire should locate nearby IMO (they didn't before, but putting to a separate module sounds too harsh).
- Global
-wno-orphans
- this sounds like a coolstory, I think orhpans are not a very good pattern so discouraging it with a warning is actually good. Or not? Also I heard that compilation time slightly increases with each module that allows orphan instances. - Trailing
--
in haddock - why not just use the same style as in the remainder of the project :pepe_stare: If everyone comes with its own preferred style (that also probably changes every several years), that would be a mess. - The separation of ignored removal and info gathering itself - really nice to obtain it 👍
- Moving functions from
where
to top-level - neat.
Well, quite a wall of comments, but this PR is sorta big too )
I would extract 1 & 1.5, maybe 4 (changed), 7 and 8 to a separate PR and leave other changes pending for now.
src/Xrefcheck/Core.hs
Outdated
instance Default FileInfo where | ||
def = FileInfo [] [] | ||
instance Semigroup FileInfo where | ||
FileInfo a b <> FileInfo c d = FileInfo (a <> c) (b <> d) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And here we get O(n^2)
for free :nabros:
Btw, it seems to me that having a builder version for some list-like type is quite a common practice, can it be generalized and put to some library 🤔
-- | ||
-- (Why isn't `Node` a type alias for `Data.Tree.Node`?) | ||
-- | ||
instance {-# overlapping #-} Show DebugNode where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it overlapping
?
import Test.Hspec (Spec, describe, it, shouldBe) | ||
|
||
import Xrefcheck.Core | ||
import Xrefcheck.Scanners.Markdown | ||
|
||
spec :: Spec | ||
spec :: HasCallStack => Spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this constraint necessary here?
src/Xrefcheck/Verify.hs
Outdated
|+ "' diverges with its label '" +| build txt | ||
|+ "',\n which might denote copy-paste that ended with either anchor\n\ | ||
\ or label left not updated\n\n" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This apparently was intended for another PR )
We didn't merge it yet. I'll update my PR soon!) |
👍 Just coordinate with @Heimdell who switches this entire project to post-qualified-imports. |
8ed8f3c
to
fae3d97
Compare
Problem: The tree traversal uses explicit recursion and does not-closely-unrelated stuff at once. Solution: Separate different actions.
fae3d97
to
8fad026
Compare
Problem: Stack cannot build projects with mixins, and they only used to splice universum instead of base. Solution: Use `NoImplicitPreduce` and import `Universum` everywhere explicitly.
Problem: In ``` import qualified Foo.Bar as Bar import Foo.Bar (Bar) ``` names of the imported modules are on different vertical lines, which disables autosorting, and makes it harder to read. Solution: Use `ImportQualifiedPost`
Problem: The tree traversal uses explicit recursion and does not-closely-unrelated stuff at once. Solution: Separate different actions.
Co-authored-by: Diogo Castro <[email protected]>
6269a80
to
878775c
Compare
@Martoon-00 do you wanna have another look at this before merging, or are you happy enough with merging as-is? |
Description
Problem: data collection is a function that calls itself 5 screens below the place it starts and is a pile of different, but unrelated actions, performed simultaneously.
Solution: divide the pile into parts and then combine parts externally.
Concrete changes
xrefcheck: ignore X
functionality is implemented as a separate function.Results
Anchor
/Reference
colelctor fits into one screen now.The Visitor API
Runs the provided action, collects the results.
Related issue(s)
None, preparing for #64
✅ Checklist for your Pull Request
Ideally a PR has all of the checkmarks set.
If something in this list is irrelevant to your PR, you should still set this
checkmark indicating that you are sure it is dealt with (be that by irrelevance).
Related changes (conditional)
Tests
silently reappearing again.
Documentation
Public contracts
of Public Contracts policy.
and
Stylistic guide (mandatory)