sourcery-ai / sourcery

Instant AI code reviews
https://sourcery.ai
MIT License
1.55k stars 68 forks source link

How do I get rid of "Sourcery Code Metrics"? #282

Closed madebylydia closed 1 year ago

madebylydia commented 2 years ago

Hi, I'm a user of VSCode & Sourcery, and I very often read the comments of methods.

I am very annoyed by the "Sourcery Code Metrics" because this is irrelevant to me and sometime is buggy. image

How do I remove it? There's no option in settings and I don't want it anywhere. Thank

Hellebore commented 2 years ago

Hi @Predeactor - thanks for getting in touch.

You can turn these off permanently by adding a setting to your user sourcery.yaml file. The file containing the setting would look like this:

refactor:
  skip:
  - function-quality

The location of this file is platform-dependent - you can find details here: https://docs.sourcery.ai/Reference/Configuration/Sources/

madebylydia commented 2 years ago

This does not seem to work Just to be sure, I've created a sourcery.yaml and .sourcery.yaml but there is no change.

Do you have anything else perhaps?

Hellebore commented 2 years ago

Hi @Predeactor that's strange - could you post the file, its location and your OS, and make sure you've restarted VS Code?

One shortcut to making this work is also to take the 'Never show me this refactoring' option on a different refactoring and then edit the file it creates by changing the refactoring id.

madebylydia commented 2 years ago

Hey, I won't answer your question yet because, to my surprise, Sourcery does not work at all now! So no point trying to fix one thing if the whole thing doesn't work. There's just no suggestion at all... image

I deleted the folder %AppData%/sourcery and rebooted VSC. Nothing change, no suggestion... And I am not working in a workspace, there's only this file opened

I'm quite stuck now... 😅

Hellebore commented 2 years ago

Oh no! Some questions:

  1. When did this start - was it after taking the 'never show me this refactoring' option?
  2. Are any error notifications shown when you start VS Code? Also could you possibly find your log file and mail it to support@sourcery.ai? That will help me diagnose the issue.

https://docs.sourcery.ai/Product/Troubleshooting/

madebylydia commented 2 years ago
  1. This has started after using your suggestion/creating a global sourcery.yaml apparently
  2. VSC has (Finally? I never had it since now) a notification:

    'charmap' codec can't encode character '\U0001fa84' in position 2: character maps to - Source: Sourcery (Extension)

I have sent you my log file in the given address!

Hellebore commented 2 years ago

Hmm - is there a sourcery folder in %LOCALAPPDATA% ? If so then could you post the contents of any sourcery.yaml file in there and then try removing it?

madebylydia commented 2 years ago

%LocalAppData%/sourcery/sourcery.yaml exist... I know where this is getting x)

Content:

refactor:
  rule_types: []

Deleted and... Oh, it works once again! I tried to re-add the content of sourcery.yaml from the beginning and surprisingly, there's no refactor again... The %LocalAppData/sourcery/sourcery.yaml kicks-in again with the same content as above Guess it shouldn't happens?

madebylydia commented 2 years ago

I added:

refactor:
  skip:
  - function-quality

to %LocalAppData/sourcery/sourcery.yaml, and this time, it works just fine! The "Sourcery Code Metrics" is no more and Sourcery work just fine!

Should I keep this issue open so you can keep track of what happened today?

Hellebore commented 2 years ago

Yes - let's leave it open since it looks like there definitely might be some weird behaviour to investigate.

Really glad you got it working!

brendanator commented 2 years ago

This configuration will stop Sourcery basically doing anything

refactor:
  rule_types: []

as it is saying don't try any rule types.

The default config for this setting is:

refactor:
  rule_types:
  - refactoring
  - suggestion
  - comment

which enables all types of rule.

@Predeactor Do you know how your config got into this state?

madebylydia commented 2 years ago

@brendanator The only thing I've done to achieve this state is to put the following into %AppData%/sourcery/sourcery.yaml:

refactor:
  skip:
  - function-quality

I guess that's because I do not specific rules in this file? 😛

brendanator commented 2 years ago

I looks like there's three issues here:

madebylydia commented 2 years ago
  • @Predeactor Do you know how this happened? Did you try clicking VSCode options to disable refactorings, suggestions and comments to switch off Sourcery metrics?

Yes, all these settings were disabled actually image I actually am wondering if they had any effects actually, I feel like it was still working as expected before I try touching the sourcery.yaml file manually.

brendanator commented 2 years ago

Thanks @Predeactor, let's assume that this emptied the rule_types then. Once the other two issues are completed I'll close this

Thanks for your detailed report and all your help 🙏

Hellebore commented 1 year ago

Made the fixes - now live.

wy6688 commented 3 months ago

how to permanently disable or remove Sourcery.ai? it's very annoy I cannot disable this modules, just feel be kidnaped by it, just malious software .