Skip to content

Fix sonar errors - #632

Open
mykola-kobets-epam wants to merge 9 commits into
aosedge:developfrom
mykola-kobets-epam:fix-sonar-errors
Open

Fix sonar errors#632
mykola-kobets-epam wants to merge 9 commits into
aosedge:developfrom
mykola-kobets-epam:fix-sonar-errors

Conversation

@mykola-kobets-epam

Copy link
Copy Markdown
Collaborator

No description provided.


State(State&&) = default;
State& operator=(State&&) = default;
State(State&&) noexcept = default;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove . at the end of commit message

}

digest = it->mIndexDigest;
digest = it->mIndexDigest; // NOSONAR cpp:S5912 - Assign stays within StaticString capacity

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to find another solution.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replaced with Assign in some cases

Comment thread src/core/common/pkcs11/pkcs11.cpp Outdated
pin.Clear();

srand(::time(nullptr)); // use current time as seed for random generator
srand(::time(nullptr)); // NOSONAR cpp:S5020 - C++ <random> not available in this codebase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can randomItf be used instead?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, fixed

}

path = fs::JoinPath(mConfig.mImagePath, cLayersFolder, alg, hash);
path = fs::JoinPath(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

new Sonar issue?

Use pointer or reference to avoid slicing from "StaticString<512>" to "String".

@mykola-kobets-epam
mykola-kobets-epam force-pushed the fix-sonar-errors branch 2 times, most recently from 883ccea to 555fe27 Compare August 5, 2026 10:26
Make sure that moving an objectis "noexcept"
Move and swap operations should be "noexcept"

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Use pointer or reference to avoid slicing
Suppress false-positive slicing for String/Array views over Static*

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Replace "module" with another name

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Replace "srand"/"rand" with the facilities in <random>
Suppress: C++ <random> not available in this codebase

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Suppress false-positive lock already acquired / lock order reversal

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Use the value returned from the function

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Replace this builtin type with an alias that makes the type size explicit

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
Make an overloaded operator a hidden friend

Signed-off-by: Mykola Kobets <mykola_kobets@epam.com>
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
57.4% Coverage on New Code (required ≥ 80%)
D Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

version = it->mVersion;

return ErrorEnum::eNone;
return AOS_ERROR_WRAP(version.Assign(it->mVersion));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like to put operators into macro. Should be:

if (auto err = version.Assign(it->mVersion); !err.IsNone()) {
    return AOS_ERROR_WRAP(err);
}

reuturn ErrorEnum::eNone;

In all the cases.

}

return ErrorEnum::eNone;
return AOS_ERROR_WRAP(pin.ByteArrayToHex(buffer));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

const auto count = Min<size_t>(cAlertItemsCount, mAlerts.Size());

package->mItems.Assign(Array<AlertVariant>(mAlerts.begin(), count));
(void)package->mItems.Assign(Array<AlertVariant>(mAlerts.begin(), count));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log error

void Alerts::ShrinkCache(size_t count)
{
mAlerts.Erase(mAlerts.begin(), mAlerts.begin() + Min<size_t>(count, mAlerts.Size()));
(void)mAlerts.Erase(mAlerts.begin(), mAlerts.begin() + Min<size_t>(count, mAlerts.Size()));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log error

}

receiver->OnAlertReceived(alert);
(void)receiver->OnAlertReceived(alert);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

log error


mCancel = true;
mCondVar.NotifyAll();
(void)mCondVar.NotifyAll();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check and return error

UniqueLock<Mutex> lock(mMutex); // NOSONAR cpp:S5486 - false positive; lock released before next WaitForStop()

mCondVar.Wait(lock, cRetryTimeout, [this]() { return mCancel; });
(void)mCondVar.Wait(lock, cRetryTimeout, [this]() { return mCancel; });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto in all the cases:

either return or log error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants