3 issues with Justcode - Code Formatting if Formatting is turened off, Detection of empty statements, Unused using directives, Detection of empty statements, Not detected unused usings

7 posts, 0 answers
  1. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 11 Jul 2013 Link to this post

    Hi,

    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:

    public object SomeProperty
    {
    get { return someProperty; }
    }

    So format is turned off, i would have expected the following result
    public object SomeProperty
    {
        get { return this.someProperty; }
    }
    However i get a formated (unwanted) result:
    public object SomeProperty
    {
        get
        {
            return this.someProperty;
        }
    }

    This one makes it quite unusable for me, because i have to nearly undo every change...

    2. issue:
    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?

    3. issue: 
    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?)
  2. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 11 Jul 2013 Link to this post

    Hi Wolfgang,

     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.
    Thanks.

    Regards,
    Zdravko
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  3. DevCraft banner
  4. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 12 Jul 2013 Link to this post

    Hi Zdravko,

    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 :
    int i=1; ;
     
    This one could be removed easily, it does not change program flow at all.
    int i=1;

    With
    while(...) ; //("as long as something  is in a special state do nothing, afterwards do xyz")
    xyz;

    the deletion of the semikolon will change however the program flow. 
    while(...) xyz; // now something is executed while a condition is true, in the case before it was not executed until the condition is false

    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

    Best regards
    Wolfgang
  5. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 15 Jul 2013 Link to this post

    Hi Wolfgang,

     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?
    Thanks.

    Regards,
    Zdravko
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
  6. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 18 Jul 2013 Link to this post

    Hi Zdravko

    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.

    Best regards,
    Wolfgang
  7. Wolfgang
    Wolfgang avatar
    98 posts
    Member since:
    Oct 2012

    Posted 31 Jul 2013 Link to this post

    Hi Zdravko,

    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:
    using C******;
    using  C******.******;
    using G********;
    using iAnywhere.Data.SQLAnywhere;
    using Microsoft.Win32;
    using S***.*****;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.IO;
    using System.Runtime.ExceptionServices;
    using System.Security;
    using System.Text;
    using System.Windows.Forms;
    (I put stars where product specific classes are used).

    With Telerik JustCode:
    using C******;
    using  C******.******;
    using G********;
    using Microsoft.Win32;
    using S***.*****;
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.IO;
    using System.Runtime.ExceptionServices;
    using System.Security;
    using System.Text;
    using System.Windows.Forms;
    using iAnywhere.Data.SQLAnywhere;

    So the Sybase iAnywhere.* is sorted after System.* , which would not be alphabetically correct.

    Best Regards,
    Wolfgang
  8. Zdravko
    Admin
    Zdravko avatar
    657 posts

    Posted 01 Aug 2013 Link to this post

    Hi Wolfgang,

     Indeed you are right.
    I will add this to our system for further investigation.
    Thank you.

    Regards,
    Zdravko
    Telerik
    Share what you think about JustCode with us, so we can help you even better! You can use the built-in feedback tool inside JustCode, our forum, or our JustCode feedback portal.
Back to Top
DevCraft banner