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

3/3: Verbose Output #50

Closed
wants to merge 5 commits into from
Closed

3/3: Verbose Output #50

wants to merge 5 commits into from

Conversation

ta2edchimp
Copy link
Collaborator

  • feat: get current rules detailed config (from PR 2/3: Get Current Rules' Detailed Config #49)
  • feat(diff): compare both ways
    sample output:
    image
  • feat(find): add verbose output
  • feat(diff): add detailed comparison output
    sample output:
    image

I think, a nice extension for the "detailed comparison output" would be colorization:

  • yellow: loose equality, e.g. 2 and [2]
  • orange: both configs specify the rule, but they different, e.g. 0 and [2, "always"]
  • red: the rule is undefined in one of the configs

@codecov-io
Copy link

Current coverage is 100.00%

Merging #50 into master will not affect coverage as of b2580ce

@@            master     #50   diff @@
======================================
  Files            5       6     +1
  Stmts          127     175    +48
  Branches         0       0       
  Methods          0       0       
======================================
+ Hit            127     175    +48
  Partial          0       0       
  Missed           0       0       

Review entire Coverage Diff as of b2580ce

Powered by Codecov. Updated on successful CI builds.

@@ -32,9 +33,12 @@ Object.keys(options).forEach(function findRules(option) {
var ruleFinderMethod = ruleFinder[option]
if (argv[option] && ruleFinderMethod) {
rules = ruleFinderMethod()
argv.verbose && console.log( // eslint-disable-line no-console
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something to be considered as a follow up.
cyclomatic complexity of findRules function has increased over the time, it should be refactored.
Not in this PR

@ta2edchimp
Copy link
Collaborator Author

@sarbbottam what do you think about the idea of colorising the verbose diff output? In case it's a lot, printed on screen, I think it would definitely help getting the major differences at first glance ...

@sarbbottam
Copy link
Owner

@sarbbottam what do you think about the idea of colorising the verbose diff output?

🌈 👍

@ta2edchimp
Copy link
Collaborator Author

ta2edchimp commented Apr 18, 2016

I hope this pushed changes solve most of your notes, @sarbbottam.

  • the diff schema changed to an explicit one
    • it gets resolved to a flat array eventually though (in lib/sort-rules)
      (this is, to be able to use a single general approach to render the output, in this case the 3-columned tabular output)
  • bin/diff got some rework
    • functionality has been broken into different functions, each doing less
    • I guess, rulesDifference could still be tweaked a little, but I didn't want to "overoptimize"
  • the test for bin/find got corrected
    (the regex matching of console.log arguments went into beforeEach)

I'd propose to realize the colored output via its own PR, to not bring too much noise into this one (and we then could think about whether it would make sense to think about colorized output in general).

@sarbbottam
Copy link
Owner

I'd propose to realize the colored output via its own PR, to not bring too much noise into this one (and we then could think about whether it would make sense to think about colorized output in general).

Yep, I prefer one use-case : one PR.


I will go through the PR this afternoon.

} catch (e) {
diff[n] = {
config1: a[n],
config2: b[n],
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we prune the a[n] and b[n] from a and b respectively, after this step? Or at least b[n] from b, otherwise we will be stepping over the config which has already been considered again for

Object.keys(b).forEach(compare(diff, a, b))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do that, I guess we don't need the if (!diff[n]) any more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok to address this in a subsequent PR, provided that there is an issue opened for this. 😈

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's an interesting point, I'll consider when pulling object-diff from this PR.

@sarbbottam
Copy link
Owner

sarbbottam commented Apr 19, 2016

Sorry for being so picky, but this a big change, I highly appreciate your effort for making this tool awesome 👏 .


Here are few things, I would request.

  • ‼️ DO NOT CLOSE THIS PR
  • take out object-diff and its test in to a separate PR.
  • take out sort-rules and its test in to a separate PR (please update the o/p schema).
  • merge the above two PRs
  • rebase this pr with upstream/master,
    • changes related to
    • rule-finder.js and readme, will not be shown as part of this PR.
    • object-diff and its test, will not be shown as part of this PR.
    • sort rules and its test, will not be shown as part of this PR.
  • create an utility for displaying output with cliui
    • consider your existing use cases for the required transformations.
  • merge the above PRs
  • update bin/find to use the cliui util 💥
  • update this PR to use the cliui util for diff 💥 💥

Please let me know, if I am unclear or unreasonable.

Thanks!

@sarbbottam
Copy link
Owner

@ta2edchimp please have a look at https://github.com/substack/text-table, might be easier that cliui. It takes care of the alignment.

rule = rule + outputPadding might not be required.

@ta2edchimp
Copy link
Collaborator Author

Your points sound reasonable.

From a quick look, even text-table looks like we'd have to calculate column widths using the available width ourselves, as well as specifying the rows as arrays, so we gain no benefit over cliui in my opinion. I'd stick with the approach of the cliui util that you mentioned.

@ta2edchimp
Copy link
Collaborator Author

@sarbbottam please review #55 and #56 as soon as you got time for that and and eventually merge.
I will continue with the rest, as soon as I find the time for it.

@ta2edchimp
Copy link
Collaborator Author

Open issues of this PR continued in #61 and #62, @sarbbottam when you get the time, I'd appreciate you having a look on those again.

Closing this now, please reopen if there's still things left to discuss 😉

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

Successfully merging this pull request may close these issues.

None yet

3 participants