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
poojasureshkumarAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sarabandeCommented:
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
poojasureshkumarAuthor Commented:
Hi Sara,
I already tried that and still is giving the same report at return line.

Kind regards,
Pooja
kaufmed   ( ⚆ _ ⚆ )I asked the operating system what I could do to become a better programmer. It said, "Let me give you some pointers."Commented:
How are you calling this method? What does that code look like?
sarabandeCommented:
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
poojasureshkumarAuthor Commented:
my bad! calling unconditional  return , so the sonarqube warns that  control will not  moved to other statements. Thanks for the help guys!

Kind regards,
Pooja

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.