Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2026-04-24 11:21:04 +0200
committerMartin Hořeňovský2026-04-24 11:21:04 +0200
commit11a96e186af8b2779d93e550217e9c95d3f89371 (patch)
tree0f478d0761c8a951c9c238f5504fa020929ae7fa /src
parent10f62484bff73e3a58a411e2e10b4e1c13cfba9f (diff)
downloadcatch3-11a96e186af8b2779d93e550217e9c95d3f89371.tar.gz
Cleanups from static analysis
Diffstat (limited to 'src')
-rw-r--r--src/catch2/benchmark/detail/catch_analyse.cpp10
-rw-r--r--src/catch2/internal/catch_run_context.cpp15
-rw-r--r--src/catch2/internal/catch_run_context.hpp2
-rw-r--r--src/catch2/internal/catch_tag_alias_registry.cpp7
-rw-r--r--src/catch2/internal/catch_test_failure_exception.cpp4
-rw-r--r--src/catch2/internal/catch_test_registry.hpp2
-rw-r--r--src/catch2/reporters/catch_reporter_cumulative_base.cpp5
7 files changed, 22 insertions, 23 deletions
diff --git a/src/catch2/benchmark/detail/catch_analyse.cpp b/src/catch2/benchmark/detail/catch_analyse.cpp
index 14d7f450..8934f84f 100644
--- a/src/catch2/benchmark/detail/catch_analyse.cpp
+++ b/src/catch2/benchmark/detail/catch_analyse.cpp
@@ -36,11 +36,11 @@ namespace Catch {
samples.data(), samples.data() + samples.size() );
auto wrap_estimate = [](Estimate<double> e) {
- return Estimate<FDuration> {
- FDuration(e.point),
- FDuration(e.lower_bound),
- FDuration(e.upper_bound),
- e.confidence_interval,
+ return Estimate<FDuration>{
+ FDuration( e.point ),
+ FDuration( e.lower_bound ),
+ FDuration( e.upper_bound ),
+ e.confidence_interval,
};
};
std::vector<FDuration> samples2;
diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp
index e7e22c58..a435170f 100644
--- a/src/catch2/internal/catch_run_context.cpp
+++ b/src/catch2/internal/catch_run_context.cpp
@@ -461,14 +461,13 @@ namespace Catch {
Detail::g_lastAssertionPassed = true;
} else if (!result.succeeded()) {
Detail::g_lastAssertionPassed = false;
- if (result.isOk()) {
- }
- else if( m_activeTestCase->getTestCaseInfo().okToFail() ) // Read from a shared state established before the threads could start, this is fine
+ if (result.isOk()) {}
+ else if( m_activeTestCase->getTestCaseInfo().okToFail() ) { // Read from a shared state established before the threads could start, this is fine
m_atomicAssertionCount.failedButOk++;
- else
+ } else {
m_atomicAssertionCount.failed++;
- }
- else {
+ }
+ } else {
Detail::g_lastAssertionPassed = true;
}
@@ -650,7 +649,7 @@ namespace Catch {
// and since IResultCapture::getLastResult is deprecated,
// we will leave it as is, until it is finally removed.
Detail::LockGuard _( m_assertionMutex );
- return &(*m_lastResult);
+ return &*m_lastResult;
}
void RunContext::exceptionEarlyReported() {
@@ -902,7 +901,7 @@ namespace Catch {
}
void RunContext::populateReaction( AssertionReaction& reaction,
- bool has_normal_disposition ) {
+ bool has_normal_disposition ) const {
reaction.shouldDebugBreak = m_shouldDebugBreak;
reaction.shouldThrow = aborting() || has_normal_disposition;
}
diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp
index 4a77cac5..f333735d 100644
--- a/src/catch2/internal/catch_run_context.hpp
+++ b/src/catch2/internal/catch_run_context.hpp
@@ -123,7 +123,7 @@ namespace Catch {
ITransientExpression const *expr,
bool negated );
- void populateReaction( AssertionReaction& reaction, bool has_normal_disposition );
+ void populateReaction( AssertionReaction& reaction, bool has_normal_disposition ) const;
// Creates dummy info for unexpected exceptions/fatal errors,
// where we do not have the access to one, but we still need
diff --git a/src/catch2/internal/catch_tag_alias_registry.cpp b/src/catch2/internal/catch_tag_alias_registry.cpp
index 510df167..e87e4050 100644
--- a/src/catch2/internal/catch_tag_alias_registry.cpp
+++ b/src/catch2/internal/catch_tag_alias_registry.cpp
@@ -16,10 +16,11 @@ namespace Catch {
TagAlias const* TagAliasRegistry::find( std::string const& alias ) const {
auto it = m_registry.find( alias );
- if( it != m_registry.end() )
- return &(it->second);
- else
+ if ( it != m_registry.end() ) {
+ return &it->second;
+ } else {
return nullptr;
+ }
}
std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const {
diff --git a/src/catch2/internal/catch_test_failure_exception.cpp b/src/catch2/internal/catch_test_failure_exception.cpp
index 8ea31313..8c34278f 100644
--- a/src/catch2/internal/catch_test_failure_exception.cpp
+++ b/src/catch2/internal/catch_test_failure_exception.cpp
@@ -14,7 +14,7 @@ namespace Catch {
void throw_test_failure_exception() {
#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
- throw TestFailureException{};
+ throw TestFailureException{}; //NOLINT(bugprone-std-exception-baseclass)
#else
CATCH_ERROR( "Test failure requires aborting test!" );
#endif
@@ -22,7 +22,7 @@ namespace Catch {
void throw_test_skip_exception() {
#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
- throw Catch::TestSkipException();
+ throw Catch::TestSkipException(); //NOLINT(bugprone-std-exception-baseclass)
#else
CATCH_ERROR( "Explicitly skipping tests during runtime requires exceptions" );
#endif
diff --git a/src/catch2/internal/catch_test_registry.hpp b/src/catch2/internal/catch_test_registry.hpp
index 593593ba..213b2bdc 100644
--- a/src/catch2/internal/catch_test_registry.hpp
+++ b/src/catch2/internal/catch_test_registry.hpp
@@ -124,7 +124,7 @@ struct AutoReg : Detail::NonCopyable {
namespace Catch {
namespace Detail {
struct DummyUse {
- DummyUse( void ( * )( int ), Catch::NameAndTags const& );
+ DummyUse( void ( * )( int ), Catch::NameAndTags const& ) noexcept;
};
} // namespace Detail
} // namespace Catch
diff --git a/src/catch2/reporters/catch_reporter_cumulative_base.cpp b/src/catch2/reporters/catch_reporter_cumulative_base.cpp
index 09169632..dc5ae4b0 100644
--- a/src/catch2/reporters/catch_reporter_cumulative_base.cpp
+++ b/src/catch2/reporters/catch_reporter_cumulative_base.cpp
@@ -20,9 +20,8 @@ namespace Catch {
bool operator()(
Detail::unique_ptr<CumulativeReporterBase::SectionNode> const&
node ) const {
- return (
- ( node->stats.sectionInfo.name == m_other.name ) &&
- ( node->stats.sectionInfo.lineInfo == m_other.lineInfo ) );
+ return node->stats.sectionInfo.name == m_other.name
+ && node->stats.sectionInfo.lineInfo == m_other.lineInfo;
}
void operator=( BySectionInfo const& ) = delete;