IntelliJ Idea: How to automatically remove commented out code? - android-studio

I've run SonarQube analysis on my Android/Java project and it resulted, among others, with issues:
Sections of code should not be "commented out"
If SonarQube is able to identify them, is it possible to automatically commented out code in Android Studio? I can't just remove all comments, because there are also some that are legit.
I have 500+ of them and don't want to do it manually. Any ideas?

There is no general solution for issues reported by SonarQube since SonarQube only finds problems, it doesn't offer a way to fix them.
In this particular case of commented out code, the same check is available directly in IntelliJ.
from the menu, select "Code | Analyze Code | Run Inspection by Name"
type "commented" to select the inspection about commented code
run it on the whole project
This inspection now lists the occurrences, and the Problems tool window offers you to fix all of them at once.

Related

How keep tests shortcuts/icons once `auto-run` is switched off from the extension sidebar?

Currently Jest in my VSCode uses the --watch parameter (I use the Orta.vscode-jest extension), which mean when I save a file, it will run all tests in uncommitted files.
It's a good default behavior but sometimes my upcoming commit may imply multiple files and I don't want to waste 75% of my time and resources on tests I don't to focus on.
After reading documentation, I found I can turn off the auto-run (see arrow below), so now when saving nothing happens, and I was expecting a way to trigger manually the test I want.
Unfortunately once done it's like if the extension was totally shut down. See below, I have no longer the ability to run tests through the extension.
Do you know a way to solve this? Keeping icon buttons to trigger manually specific tests?
I saw some homemade solution https://stackoverflow.com/a/55279902/3608410 (see Running a selected Jest test in Visual Studio Code) but I feel it's weird since we have a powerful extension already installed.
(maybe I missed something...)
Thank you,
Didn't see that before but if doing a right click in the test file where needed, in the menu I'm able to run a specific test, handy!

Resharper analyses files when solution is loaded even if solution wide analysis is off

When I open the solution I am working with, resharper takes some minutes to analyse the solution, making the IDE unresponsive.
Why does it do that if I had turned off solution wide analysis?
edit
I have got an answer that there is no actual analyze on startup if I turned off "solution wide analysis". However, on startup, there is a red animated icon in the lower right corner of the window and if I click that, the tooltip reads "Analyzing files (8 of 431)" so the suggestion that there is no solution wide analysis is contradicted by the wording.
there are multiple things you can try on the first hand.
have you trying reading
this link
or you can try showing the execution time for the solution analysis then you can see where it got stuck for minutes.
or you can try this too.
Go to ReSharper | Options | Environment | Performance Guide to check and quickly fix ReSharper and Visual Studio preferences that affect performance.
If you do not use solution-wide analysis, disable it or consider disabling warnings in solution-wide analysis. Even if it is disabled, you can find all code issues in your solution at any time by running code inspection for the whole solution. To configure solution-wide analysis, go to ReSharper | Options | Code Inspection | Settings.
In Visual Studio options, go to Source Control | Plug-in Selection: select None for the source control plugin. This will turn off Git or another VCS provider and improve overall performance.
ReSharper builds or updates indexes on startup. The indexes are used for basic ReSharper's functionality: navigation, refactoring, code analysis in open files, etc...
If you see IDE unresponsiveness, you can collect timeline perfomance snapshot and send it to JetBrains for investigation. Instructrions for submitting performance problem can be found here (you need to select "Performance snapshot(timeline)":
https://resharper-support.jetbrains.com/hc/en-us/articles/207243205-How-to-collect-a-performance-snapshot-and-send-it-to-JetBrains-Team

How to delete unused java and xml files from Android Studio

I want to do clean up my project which having 1000+ Java classes, but many of them are not in used. Is there easiest way to track unused classes and xmls.
You can analyze your whole project to find XML, code and all things that are unused or not required with Lint
With this you can find unused classes, resources, security leaks,
refactor suggestions and more, it's really useful.
First right click on your project main package, select Analyze - Inspect Code.
After that select whole project
Then you can see all your problems to fix
An example of an XML error, you can see the errors from the drop down and in the right where they are located, and also you can fix all this problems from the same inspector, above you can see suppress, that is a way to fix this, and you move on to all project problems with this
Also, you can remove unwanted resources like this, right click in your project structure
you can select preview and see all the resources which you can delete
Refactor - Remove unused Resources...

What is the general approach to fixing Go To functionality in Resharper

I often see that some of the ReSharper functionality just doesn't work until you restart VS and reopen the project. But this situation I have now is consistent across restarts. So I am using a Go To Everything fuctionality often. It is enabled in ReSharper settings.
But since yesterday Go To Everything (Ctrl + N for me) can't find most of the files in the project (though it can find some).
Here is a screenshot of the problem:
I have that file open in editor just to prove that it's there. I show it found in an open solution in file tree. But ReSharper doesn't seem to be able to find it.
What to I do to troubleshoot. Thanks you in advance.
The best thing to do here is to raise an issue with JetBrains. Either log a bug with the issue tracker, or email resharper-support#jetbrains.com. Include details about what version of ReSharper you're using, what type of projects you're using, version of Visual Studio, etc.
However, from that screenshot, it looks like ReSharper isn't configured to analyse that file - there's no "green tick" in the scrollbar. Is ReSharper disabled? Is that file excluded from analysis? (Mind you, even when it's excluded, it should still show up in go to results. Something odd is happening here, support should be able to help better than StackOverflow)

Resharper warnings window

I'm using ReSharper for my solution (that contains 10 projects) and I'd like to see the hints/suggestions/warnings/errors (listed in a window) for a chosen project. How can I do that?
Note: the solution analyzer window shows only errors.
In ReSharper 5, you can right-click solution explorer and select Inspect Code. It will show you all the issues found in the selected scope. There is a button on the toolbar to filter issues.
Doesn't seem to be an available option with the current release of Resharper...
We are not going to include warnings
in SWA in ReSharper 4 release cycle.
This is due to complexity of some of
analyses, due to complexity of UI to
deal with thousands of possible
warnings, and so on and so forth. We
are going to improve SWA in many ways,
we have a lot of plans, but they need
some time to implement. I can't say
any specific dates right now, but I
think we can add more solution-wide
features in the next major release
after ReSharper
4.0.
As a workaround, you can set severity of warnings you are
interested in to the "error" level.
You may have to restart VS to force
SWA reanalyse files.
Source:
http://www.jetbrains.net/devnet/thread/273096

Resources