Link to home
Start Free TrialLog in
Avatar of suresh pondicherry
suresh pondicherryFlag for United States of America

asked on

Fix sonarqube complaints for .net application

Hi,
Thanks!
This is regarding sonarqube complaint. I am using

public async Task<(Guid, string, Guid)> GetAllCategories()
{
    return (Guid.Parse(data["Id"].ToString()),
            data["StatusName"].ToString(),
            Guid.Parse(data["StatusId"].ToString())
    );
}

Open in new window


Sonarqube is complaining "Remove this return statement or make it conditional" . Please help me how to fix this bug..

Kind regards,
Pooja
Avatar of sarabande
sarabande
Flag of Luxembourg image

you may try the following:

public async Task<(Guid, string, Guid)> GetAllCategories()
{
       Guid guidId = Guid.Parse(data["Id"].ToString()) ;
       string statusId = data["StatusName"].ToString();
       Guid guidStatusId = Guid.Parse(data["StatusId"].ToString());
       return (guidId, statusId, guidStatusId);
}

Open in new window


shouldn't make much difference but perhaps gives better error message.

Sara
Avatar of suresh pondicherry

ASKER

Hi Sara,
I already tried that and still is giving the same report at return line.

Kind regards,
Pooja
How are you calling this method? What does that code look like?
can you try to using 3 tasks instead of one:

public async Task<Guid> GetAllCategoriesIdGuid()
{
       Guid guidId = Guid.Parse(data["Id"].ToString()) ;
       return guidId;
}

public async Task<string> GetAllCategoriesStatusName()
{
       string statusId = data["StatusName"].ToString();
       return statusId;
}

public async Task<Guid> GetAllCategoriesStatusIdGuid()
{
       Guid guidStatusId = Guid.Parse(data["StatusId"].ToString());
       return guidStatusId;
}

Open in new window


Sara
ASKER CERTIFIED SOLUTION
Avatar of suresh pondicherry
suresh pondicherry
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial