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

Combine semi-active forks into one #5

Open
wants to merge 31 commits into
base: master
Choose a base branch
from

Conversation

vrybas
Copy link

@vrybas vrybas commented Sep 17, 2014

Greetings,

It looks like this fork is the most active one.

In this PR I've merged valuable code from onemastartup fork, fixed
few bugs myself, and resolved conflicts with this fork.

network_graph_ _onemanstartup_vim-flog

Summary of changes

Highlighting

Use Vim standard highlighting groups. No need to use variables and
UpdateHighlighting() calls. Colors can be set like this

".vimrc
  highlight SignLowComplexity     guifg=#009900 guibg=NONE ctermfg=2 ctermbg=NONE
  highlight SignMediumComplexity  guifg=#bbbb00 guibg=NONE ctermfg=3 ctermbg=NONE
  highlight SignHighComplexity    guifg=#ff2222 guibg=NONE ctermfg=1 ctermbg=NONE

Works for me. If there's any issues, I guess they can be addressed in
the future.

Enable/Disable/Toggle functions

You can also turn flog off and on:

* Turn on flog
    `:call FlogEnable()`

* Turn off flog
    `:call FlogDisable()`

* Toggle flog
    `:call FlogToggle()`

I've resolved conflicts in favor of Flog*() function names, because
they show right away from which plugin function comes from and easier
accessible with autocomplete, like :call Fl<Tab>

RubyParser

The whole complex method process_defs(exp) is gone and replaced with
use of RubyParser, which is used by Flog itself. It reduces
parsing blow-ups, but not all of them. There are some rare cases left.

Add ability to hide low and middle complexity levels

@alexbel awesome contribution. I've cherry-picked it and slightly
changed behaviour of how signs get 'placed' and 'unplaced'.

Unplace signs only in current buffer

Commit 784835d introduced a bug when you got multiple buffers opened in
multiple windows. See bed787a

Put dummy FlogDummySign before setting real signs

This is what vim-gitgutter also does. Without this the sign column
jumps back & forth when show_complexity() is executed and there's
no any signs to show.

So the whole plugin need to be refactored and there are still a few
bugs, but this can be a good start of it's new life.

Michal Humpula and others added 28 commits November 18, 2012 13:33
* origin/develop:
  fix empty .rb file opening
  oops ! Why was this line commented out ?
  fix FlogToggle function
  simplify return_report def
  update complexity after saving the buffer
Requesting a pull to vrybas:master from vrybas:onemanstartup
That's a trade-off between speed & convenience
Commit 784835d introduced a bug when you got multiple buffers opened in
multiple windows.

If you unplace signs in all opened windows, they're going to be placed
back by `show_complexity()` only in current window. But all other
windows will jump for a few pixels to the left, which is ugly.

The proper fix for original bug (when even current buffer signs weren't
unplaced) would be to use `*` together with `file`:

```
:sign unplace * file={fname}
		Remove all placed signs in file {fname}.
```
(via @alexbel) + refactor

Also set `FlogDummySign` to avoid sign column 'jumps' on files, where no
signs have been set.
Conflicts:
	README.md
	plugin/flog.vim
@alexbel
Copy link

alexbel commented Sep 17, 2014

That's a lot of work! Good job.
However, I'm not sure that removing the original author (@skammer) is a good idea.

Highlighting. From user's point of view it's much easier to set let g:flog_low_color=#color which is much readable than long line.

FlogEnable() calls ShowComplexity which calls show_complexity which would work for any type of file. I didn't check that maybe I'm wrong.

@vrybas
Copy link
Author

vrybas commented Sep 17, 2014

@alexbel,

I'm not sure that removing the original author (@skammer) is a good
idea.

Yes, absolutely. Reverted this line.

FlogEnable() calls ShowComplexity which calls show_complexity which
would work for any type

There's ignore_files regex in ShowComplexity() function, which
ignores certain types of files. Need to be extracted to an option, and
maybe moved out from ShowComplexity(). But I'd prefer to
discuss it in next PR.

it's much easier to set let g:flog_low_color=#color

Hmm, highlight groups are meant to be used for this kind of tasks.
I guess most of plugins, which play with colors, rely on highlight
groups, which can be reloaded by user in his config. GitGutter,
Fugitive to name a few.

But I'm ok with both. Let's gather some more opinions though.

vrybas added 2 commits October 6, 2015 13:16
Looks like Vim allows to put maximum of 2 symbols in Sign Column. The
solution of previous author was to show "9+" as complexity score. But it
blows up on very next line with exception:

    Error detected while processing function ShowComplexity:
    line 20: ArgumentError: comparison of String with 15 failed

The solution is to show maximum of 99 complexity value, even if
complexity exceeds 100.
Complexity scores shown in Vim and with flog CLI were radically
different. I suspect it's because, instead of analyzing actual Ruby
source, RubyParser was analyzing AST instead.
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.

5 participants