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

Fix repetition in bear collection #2594

Closed
wants to merge 1 commit into from

Conversation

whonut
Copy link
Contributor

@whonut whonut commented Aug 8, 2016

Addresses #2075.

I'm not sure if this is what @sils1297 has in-mind, but it does fix the issue of bears being collected multiple times.

@whonut
Copy link
Contributor Author

whonut commented Aug 8, 2016

I forgot to run the tests...

@Adrianzatreanu
Copy link
Contributor

hey you have some partial coverage thingies (the ones with yellow) because the else branches are not being tested. to fix this, you need to test the cases in which the if condition is not met :)

@whonut
Copy link
Contributor Author

whonut commented Aug 9, 2016

I've been trying to sort that since yesterday D: The one thing I can't do is find a GlobalBear to test the bear.kind() conditional with.

bears_by_section[section_name] = list(section.get("bears", ""))

bears_to_collect = set(chain.from_iterable(bears_by_section.values()))
bear_dirs_to_collect = set(chain(*bear_dirs_by_section.values()))
Copy link
Member

Choose a reason for hiding this comment

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

first you use chain.from_iterable and then chain with *, just use one of them consistenly shall we? ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I confess I did this for the sake of line length. Hobgoblin of Little Minds
and all that...

On 10 Aug 2016 08:35, "Lasse Schuirmann" notifications@github.com wrote:

In coalib/settings/SectionFilling.py
#2594 (comment):

 for section_name, section in sections.items():
  •    bear_dirs = section.bear_dirs()
    
  •    bears = list(section.get("bears", ""))
    
  •    section_local_bears, section_global_bears = collect_bears(
    
  •        bear_dirs,
    
  •        bears,
    
  •        [BEAR_KIND.LOCAL, BEAR_KIND.GLOBAL],
    
  •        log_printer)
    
  •    all_bears = copy.deepcopy(section_local_bears)
    
  •    all_bears.extend(section_global_bears)
    
  •    fill_section(section, acquire_settings, log_printer, all_bears)
    
  •    bear_dirs_by_section[section_name] = section.bear_dirs()
    
  •    bears_by_section[section_name] = list(section.get("bears", ""))
    
  • bears_to_collect = set(chain.from_iterable(bears_by_section.values()))
  • bear_dirs_to_collect = set(chain(*bear_dirs_by_section.values()))

first you use chain.from_iterable and then chain with *, just use one of
them consistenly shall we? ;)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/coala-analyzer/coala/pull/2594/files/d33f368876807bf83487f02330eeb47dfae37c24#r74198024,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ADrZ-M4IaROnb8BzfIoCAZZ673m32sPpks5qeX9YgaJpZM4JfA00
.

@Makman2
Copy link
Member

Makman2 commented Aug 17, 2016

ping :)
@whonut do you need help? :D

@whonut
Copy link
Contributor Author

whonut commented Aug 18, 2016

@Makman2 I'm not sure that I can proceed without some decisions being made about the corner case @sils1297 mentioned above.

@AbdealiLoKo
Copy link
Contributor

@whonut I'm not sure what discussions were made before. Could you please elaborate on what corner case @sils1297 mentioned (a link if possible, or a summary of discussions) ?

@whonut
Copy link
Contributor Author

whonut commented Sep 22, 2016

@AbdealiJK Apologies for leaving this half-finished for so long. Life got in the way. I have a few days free at least now. This is the only discussion I can find of it on Gitter with a quick search.

In summary (and as far as I can remember), my change doesn't allow bears with the same class name but defined in different files (e.g. SomeBear in foo/SomeBear.py and SomeBear in bar/SomeBear.py) to be treated separately. As far as I could tell at the time, the release version of coala didn't do this either. It makes some sense as a behaviour though, even if naming different bears identically is to be discouraged.

I hope that's helpful.

@AbdealiLoKo
Copy link
Contributor

I think you can ignore two bears with same name but different paths for now. The coala -b flag doesn't support that either to the best of my knowledge. It just chooses one of them (probably randomly)

So make an issue for bears with same name not working correctly in many places, as it would have to be fixed in many places not just this one. (show bears, mentioning bears in cli, mentioning bear as a dependency, etc)

@whonut
Copy link
Contributor Author

whonut commented Sep 23, 2016

@AbdealiJK Will do. I just updated my branch by pulling from upstream, but I just realised that the commit title is overlong. D'oh, not sure what to do about that. Sorry.

I'll fix any CI issues now if I can.

@gitmate-bot gitmate-bot added size/L and removed size/M labels Sep 23, 2016
@AbdealiLoKo
Copy link
Contributor

Hey, so we don't allow Merge commits like the one you pushed here into master normally. WHat you need to do is rebase on the current master - http://docs.coala.io/en/latest/Developers/Git_Basics.html?highlight=rebase#rebasing

@whonut
Copy link
Contributor Author

whonut commented Sep 23, 2016

OK cool. I did that before, don't know why I forgot. Do I need to do anything before rebasing?

Also, I'm not entirely sure how to fix that failing test.

bears_to_collect,
[BEAR_KIND.LOCAL, BEAR_KIND.GLOBAL],
log_printer)
all_bears = copy.deepcopy(all_local_bears)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a deepcopy ? Can't we just chain these ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Honestly I can't remember, chain should work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't work properly with just chain, I have to call list on it which makes me think it's something to do with depleting the chain generator. That confuses me though, because I only refer to all_bears once.

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@whonut
Copy link
Contributor Author

whonut commented Mar 1, 2017

I would like to pick this up again if that's OK. If you'd rather I pick up a newcomer or difficulty low issue that's fine. I can only apologise again for inactivity, February was mad. If you're OK with me picking this up, I should be able to start tomorrow.

@Makman2
Copy link
Member

Makman2 commented Mar 1, 2017

@whonut everything alright, no need for apologies :) And sure you can continue to work, "my next project" means I'm gonna start it... somewhen, so, in ~10 years :P

@Makman2 Makman2 removed their assignment Mar 1, 2017
@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

22 similar comments
@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@gitmate-bot
Copy link
Collaborator

Hey! This pull request hasn't been updated for a while :/ It would be nice if we could get this going again!

@Makman2
Copy link
Member

Makman2 commented Dec 18, 2017

Closing due to inactivity.

@Makman2 Makman2 closed this Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

6 participants