I have made the following Code Cleaning ptions:
[x] Arrange 'this' qualifier
[x] Remove empty statements
[x] Remove unused using directives
I encountered with autoformat of one class 3 problems:
1. Format code is NOT choosen.
Mainly because i want to keep some things in one line:
So format is turned off, i would have expected the following result
However i get a formated (unwanted) result:
This one makes it quite unusable for me, because i have to nearly undo every change...
I would like to detect the empty methods and clean them.
Somehow it should not clean the following code:
while(Queue.Take) ; //(while something is cleared / processed, do nothing else, one of the ways to clear a concurrent IConsumerProducerCollection)
Can this be excluded somehow?
This is just funny. If i let remove JustCode unused usings, the usings are formated in a quite ugly way.
If I afterwards let Visual Studio remove and format the usings, I get less usings, therefore JustCode does not detect some unused usings (like Linq?)
6 Answers, 1 is accepted
Thanks for your feedback.
1.By default JustCode is formatting every code span that has changed by its Code Cleaning steps. In you case "Arrange 'this' qualifier" step is changing the "get" accessor body. You can disable this setting in order to fulfill your expectations when you run the Code Cleaner.
2. Can you describe what is empty method according to you? The one with empty body or such that does nothing is his body?
An example with code snippets would be great.
3. JustCode does not remove the using directives added to this list. Also, you will notice at the top of this Options page that there is a check box that is responsible for the sorting of the using directives.
The issue with #1 is, that there is an explizit field "[ ] Format Code". I would have expected that o code would be formated if the setting is not choosen.
I think i have disabled "Adjust Lines on autoformat" and something else in the meantime, and it also does not format the lines.afterwards even with your shown setting enabled.
Therefore other combinations of settign seem to have the same effect then removing ther one shown on the page. It's a bit complicated to find the correct setting, is it somehow possible to let JustCode show which setting was applied on a ine?
With 2: an empty useless statement for me is something like the second semikolon in :
This one could be removed easily, it does not change program flow at all.
the deletion of the semikolon will change however the program flow.
The change of program flow however is something a compiler will not detect, as it is 100% correct code, but the remove creates a complete other result. Therefore it would be nice to distinct between an empty, useless statement, and an empty statement which changes the program flow.
3. Thanx, just missed the setting
Thanks for the reply.
Regarding your first problem I missed to mention 'Adjust lines on auto format' setting which affects the Formatter because when you execute a Cleaning step an Auto format is called for the changed lines of code. That is why it is better in your case.
The 'Format Code' cleaning step formats the whole file not only the changed lines. Imagine that you execute 'Remove unused variables' , the code is not formatted and all the empty lines are left behind. That is why we call an auto format for the changed parts of code.
2. We handle the situation with the provided example by adding an empty block when the semicolon is removed and the next statement is no longer a part of the 'while' statement.
Does this work for you?
now I understand 1 a bit better (even if it is a bit unexpected if first encountered).
2 : It would work, but somehow it was reduced to nothing. (Didn't find the exact example). With another peace i see that the semicolon is replaced by brackets. That works fine.
I still think that the sorting/remove of using does not work correctly.
I gave an example:
The options in Code Style, C#, Using Directives are:
[ ] Put System.namespaces on top is deselected
Both other areas have nothing in.
With Visual Studios sort:
(I put stars where product specific classes are used).
With Telerik JustCode:
So the Sybase iAnywhere.* is sorted after System.* , which would not be alphabetically correct.
Indeed you are right.
I will add this to our system for further investigation.