Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: add static analysis action #137

Merged
merged 12 commits into from
Dec 29, 2023
Merged

ci: add static analysis action #137

merged 12 commits into from
Dec 29, 2023

Conversation

finger563
Copy link
Contributor

@finger563 finger563 commented Dec 28, 2023

Description

  • Add static_analysis action for performing static analysis of the code when making changes
  • Update code to fix any issues found by static analysis
  • Removed state_machine/include/magic_enum.hpp and replaced with external/magic_enum submodule (which is included by the state_machine component)
  • Fixed bug in led class related to semaphore access / management (found by SA)

Motivation and Context

Helps ensure code quality by checking mistakes or bad programming practices. Also helps with code consistency.

How has this been tested?

Building the examples in this PR and checking that the static analysis PR action runs and produces meaningful output.

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

Copy link

github-actions bot commented Dec 28, 2023

⚡ Static analysis result ⚡

🔴 cppcheck found 6 issues! Click here to see details.

BinaryPredicate&& pred = {}) {
using result_t = std::invoke_result_t<ResultGetterType>;
using hash_t = std::conditional_t<no_duplicate<GlobValues, Hash>(), Hash, typename Hash::secondary_hash>;
constexpr std::array _values = *GlobValues;
constexpr std::size_t size = _values.size();
constexpr std::array cases = calculate_cases<GlobValues, hash_t>(Page);

!Line: 863 - information: ValueFlow analysis is limited in constexpr_switch. Use --check-level=exhaustive if full analysis is wanted. [checkLevelNormal]

crc = (crc >> 8) ^ crc_table[(crc ^ static_cast<std::uint32_t>(c)) & 0xff];
}
return crc ^ 0xffffffffL;
}
struct secondary_hash {

!Line: 731 - style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm]

acc = ((acc ^ static_cast<std::uint64_t>(c)) * static_cast<std::uint64_t>(16777619ULL)) & (std::numeric_limits<std::uint32_t>::max)();
}
return static_cast<std::uint32_t>(acc);
}
};
};

!Line: 741 - style: Consider using std::accumulate algorithm instead of a raw loop. [useStlAlgorithm]

[[maybe_unused]] static constexpr char to_lower(char c) noexcept {
return (c >= 'A' && c <= 'Z') ? static_cast<char>(c + ('a' - 'A')) : c;
}
public:
template <typename L, typename R>

!Line: 255 - style: Unused private function: 'case_insensitive::to_lower' [unusedPrivateFunction]

for (const auto c : value) {
crc = (crc >> 8) ^ crc_table[(crc ^ static_cast<std::uint32_t>(c)) & 0xff];
}
return crc ^ 0xffffffffL;
}

!Line: 730 - information: Unmatched suppression: useStlAlgorithm [unmatchedSuppression]

for (const auto c : value) {
acc = ((acc ^ static_cast<std::uint64_t>(c)) * static_cast<std::uint64_t>(16777619ULL)) & (std::numeric_limits<std::uint32_t>::max)();
}
return static_cast<std::uint32_t>(acc);
}
};

!Line: 740 - information: Unmatched suppression: useStlAlgorithm [unmatchedSuppression]


@finger563 finger563 added enhancement New feature or request ci continuous integration code quality labels Dec 29, 2023
@finger563 finger563 merged commit bdcab9c into main Dec 29, 2023
48 checks passed
@finger563 finger563 deleted the ci/static_analysis branch December 29, 2023 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci continuous integration code quality enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant