Skip to content

Commit

Permalink
Several explicit constructors per the Cppcheck report.
Browse files Browse the repository at this point in the history
  • Loading branch information
mpimenov authored and Arsentiy Milchakov committed Apr 15, 2019
1 parent 25087ac commit 1d0428d
Show file tree
Hide file tree
Showing 55 changed files with 98 additions and 89 deletions.
2 changes: 1 addition & 1 deletion android/jni/com/mapswithme/opengl/android_gl_utils.hpp
Expand Up @@ -12,7 +12,7 @@ namespace android
class ConfigComparator
{
public:
ConfigComparator(EGLDisplay display);
explicit ConfigComparator(EGLDisplay display);

bool operator()(EGLConfig const & l, EGLConfig const & r) const;
int configWeight(EGLConfig const & config) const;
Expand Down
2 changes: 1 addition & 1 deletion base/base_tests/buffer_vector_test.cpp
Expand Up @@ -279,7 +279,7 @@ struct CopyCtorChecker
std::string m_s;

CopyCtorChecker() = default;
CopyCtorChecker(char const * s) : m_s(s) {}
explicit CopyCtorChecker(char const * s) : m_s(s) {}
CopyCtorChecker(CopyCtorChecker const & rhs)
{
TEST(rhs.m_s.empty(), ("Copy ctor is called only in resize with default element"));
Expand Down
2 changes: 1 addition & 1 deletion base/base_tests/cache_test.cpp
Expand Up @@ -30,7 +30,7 @@ class SimpleFunctor
class SimpleMovableFunctor
{
public:
SimpleMovableFunctor(std::vector<char> * v) : m_v(v) {}
explicit SimpleMovableFunctor(std::vector<char> * v) : m_v(v) {}

// movable
SimpleMovableFunctor(SimpleMovableFunctor && other)
Expand Down
2 changes: 1 addition & 1 deletion base/base_tests/condition_test.cpp
Expand Up @@ -11,7 +11,7 @@ struct ConditionThread : public threads::IRoutine
{
ThreadedList<int> * m_tl;

ConditionThread(ThreadedList<int> * tl) : m_tl(tl)
explicit ConditionThread(ThreadedList<int> * tl) : m_tl(tl)
{}

void Do()
Expand Down
2 changes: 1 addition & 1 deletion base/base_tests/ref_counted_tests.cpp
Expand Up @@ -8,7 +8,7 @@ namespace
{
struct Resource : public RefCounted
{
Resource(bool & destroyed) : m_destroyed(destroyed) { m_destroyed = false; }
explicit Resource(bool & destroyed) : m_destroyed(destroyed) { m_destroyed = false; }

~Resource() override { m_destroyed = true; }

Expand Down
4 changes: 2 additions & 2 deletions base/base_tests/threads_test.cpp
Expand Up @@ -13,7 +13,7 @@ static size_t const MAX_COUNT = 1000000;

struct GeneratorThread : public threads::IRoutine
{
GeneratorThread(Vector & vec) : m_vec(vec) {}
explicit GeneratorThread(Vector & vec) : m_vec(vec) {}

virtual void Do()
{
Expand All @@ -28,7 +28,7 @@ struct GeneratorThread : public threads::IRoutine

struct ReaderThread : public threads::IRoutine
{
ReaderThread(Vector & vec) : m_vec(vec) {}
explicit ReaderThread(Vector & vec) : m_vec(vec) {}

virtual void Do()
{
Expand Down
4 changes: 2 additions & 2 deletions base/logging.hpp
Expand Up @@ -52,7 +52,7 @@ void LogMessageTests(LogLevel level, SrcPoint const & srcPoint, std::string cons
// }
struct ScopedLogLevelChanger
{
ScopedLogLevelChanger(LogLevel temporaryLogLevel = LERROR) { g_LogLevel = temporaryLogLevel; }
explicit ScopedLogLevelChanger(LogLevel temporaryLogLevel = LERROR) { g_LogLevel = temporaryLogLevel; }

~ScopedLogLevelChanger() { g_LogLevel = m_old; }

Expand All @@ -61,7 +61,7 @@ struct ScopedLogLevelChanger

struct ScopedLogAbortLevelChanger
{
ScopedLogAbortLevelChanger(LogLevel temporaryLogAbortLevel = LCRITICAL)
explicit ScopedLogAbortLevelChanger(LogLevel temporaryLogAbortLevel = LCRITICAL)
{
g_LogAbortLevel = temporaryLogAbortLevel;
}
Expand Down
2 changes: 1 addition & 1 deletion coding/coding_tests/uri_test.cpp
Expand Up @@ -19,7 +19,7 @@ namespace
class TestUri
{
public:
TestUri(string const & uri) { m_uri = uri; }
explicit TestUri(string const & uri) { m_uri = uri; }
TestUri & Scheme(string const &scheme) { m_scheme = scheme; return *this; }
TestUri & Path(string const & path) { m_path = path; return *this; }
TestUri & KV(string const & key, string const & value)
Expand Down
2 changes: 1 addition & 1 deletion coding/mmap_reader.cpp
Expand Up @@ -26,7 +26,7 @@ class MmapReader::MmapData
uint8_t * m_memory;
uint64_t m_size;

MmapData(string const & fileName)
explicit MmapData(string const & fileName)
{
// @TODO add windows support
#ifndef OMIM_OS_WINDOWS
Expand Down
2 changes: 1 addition & 1 deletion coding/zip_creator.cpp
Expand Up @@ -26,7 +26,7 @@ class ZipHandle
zipFile m_zipFileHandle;

public:
ZipHandle(string const & filePath)
explicit ZipHandle(string const & filePath)
{
m_zipFileHandle = zipOpen(filePath.c_str(), 0);
}
Expand Down
2 changes: 1 addition & 1 deletion coding/zip_reader.cpp
Expand Up @@ -14,7 +14,7 @@ namespace
class UnzipFileDelegate : public ZipFileReader::Delegate
{
public:
UnzipFileDelegate(string const & path)
explicit UnzipFileDelegate(string const & path)
: m_file(make_unique<FileWriter>(path)), m_path(path), m_completed(false)
{
}
Expand Down
2 changes: 1 addition & 1 deletion editor/new_feature_categories.hpp
Expand Up @@ -21,7 +21,7 @@ class NewFeatureCategories
using TypeName = std::string;
using TypeNames = std::vector<TypeName>;

NewFeatureCategories(editor::EditorConfig const & config);
explicit NewFeatureCategories(editor::EditorConfig const & config);

NewFeatureCategories(NewFeatureCategories && other);

Expand Down
2 changes: 1 addition & 1 deletion editor/osm_editor.cpp
Expand Up @@ -84,7 +84,7 @@ array<XmlSection, 4> const kXmlSections = {{{FeatureStatus::Deleted, kDeleteSect

struct LogHelper
{
LogHelper(MwmSet::MwmId const & mwmId) : m_mwmId(mwmId) {}
explicit LogHelper(MwmSet::MwmId const & mwmId) : m_mwmId(mwmId) {}

~LogHelper()
{
Expand Down
5 changes: 3 additions & 2 deletions feature_list/feature_list.cpp
Expand Up @@ -48,7 +48,8 @@ class ClosestPoint
double m_distance = numeric_limits<double>::max();

public:
ClosestPoint(m2::PointD const & center) : m_center(center), m_best(0, 0) {}
explicit ClosestPoint(m2::PointD const & center) : m_center(center), m_best(0, 0) {}

m2::PointD GetBest() const { return m_best; }

void operator()(m2::PointD const & point)
Expand Down Expand Up @@ -182,7 +183,7 @@ class Processor
search::LocalityFinder m_finder;

public:
Processor(DataSource const & dataSource)
explicit Processor(DataSource const & dataSource)
: m_geocoder(dataSource)
, m_boundariesTable(dataSource)
, m_villagesCache(m_cancellable)
Expand Down
2 changes: 1 addition & 1 deletion indexer/categories_index.hpp
Expand Up @@ -22,7 +22,7 @@ class CategoriesIndex

CategoriesIndex() : m_catHolder(&GetDefaultCategories()) {}

CategoriesIndex(CategoriesHolder const & catHolder) : m_catHolder(&catHolder) {}
explicit CategoriesIndex(CategoriesHolder const & catHolder) : m_catHolder(&catHolder) {}

CategoriesIndex(CategoriesIndex && other)
: m_catHolder(other.m_catHolder), m_trie(move(other.m_trie))
Expand Down
2 changes: 1 addition & 1 deletion indexer/feature.cpp
Expand Up @@ -141,7 +141,7 @@ class BitSource
uint8_t m_pos;

public:
BitSource(char const * p) : m_ptr(p), m_pos(0) {}
explicit BitSource(char const * p) : m_ptr(p), m_pos(0) {}

uint8_t Read(uint8_t count)
{
Expand Down
6 changes: 4 additions & 2 deletions indexer/indexer_tests/categories_test.cpp
Expand Up @@ -31,8 +31,8 @@ char const g_testCategoriesTxt[] =

struct Checker
{
size_t & m_count;
Checker(size_t & count) : m_count(count) {}
explicit Checker(size_t & count) : m_count(count) {}

void operator()(CategoriesHolder::Category const & cat)
{
switch (m_count)
Expand Down Expand Up @@ -89,6 +89,8 @@ struct Checker
TEST(false, ("Too many categories"));
}
}

size_t & m_count;
};

UNIT_TEST(LoadCategories)
Expand Down
2 changes: 1 addition & 1 deletion indexer/indexer_tests/search_string_utils_test.cpp
Expand Up @@ -18,7 +18,7 @@ namespace
class Utf8StreetTokensFilter
{
public:
Utf8StreetTokensFilter(vector<pair<string, size_t>> & cont)
explicit Utf8StreetTokensFilter(vector<pair<string, size_t>> & cont)
: m_cont(cont)
, m_filter([&](UniString const & token, size_t tag)
{
Expand Down
2 changes: 1 addition & 1 deletion indexer/indexer_tests/visibility_test.cpp
Expand Up @@ -32,7 +32,7 @@ class DoGetMaxLowMinHighZoom
}

public:
DoGetMaxLowMinHighZoom(Classificator const & c)
explicit DoGetMaxLowMinHighZoom(Classificator const & c)
: m_classif(classif()), m_res(-1, 1000)
{
char const * arr[][2] = {
Expand Down
2 changes: 1 addition & 1 deletion indexer/locality_index_builder.cpp
Expand Up @@ -21,7 +21,7 @@ class LocalityVector
DISALLOW_COPY(LocalityVector);

public:
LocalityVector(Reader const & reader) : m_recordReader(reader, 256 /* expectedRecordSize */) {}
explicit LocalityVector(Reader const & reader) : m_recordReader(reader, 256 /* expectedRecordSize */) {}

template <class ToDo>
void ForEach(ToDo && toDo) const
Expand Down
2 changes: 1 addition & 1 deletion indexer/rank_table.cpp
Expand Up @@ -90,7 +90,7 @@ class RankTableV0 : public RankTable
public:
RankTableV0() = default;

RankTableV0(vector<uint8_t> const & ranks) : m_coding(ranks) {}
explicit RankTableV0(vector<uint8_t> const & ranks) : m_coding(ranks) {}

// RankTable overrides:
uint8_t Get(uint64_t i) const override
Expand Down
2 changes: 1 addition & 1 deletion indexer/search_delimiters.hpp
Expand Up @@ -15,7 +15,7 @@ class Delimiters
class DelimitersWithExceptions
{
public:
DelimitersWithExceptions(std::vector<strings::UniChar> const & exceptions);
explicit DelimitersWithExceptions(std::vector<strings::UniChar> const & exceptions);

bool operator()(strings::UniChar c) const;

Expand Down
2 changes: 1 addition & 1 deletion indexer/search_string_utils.hpp
Expand Up @@ -97,7 +97,7 @@ class StreetTokensFilter
using Callback = std::function<void(strings::UniString const & token, size_t tag)>;

template <typename TC>
StreetTokensFilter(TC && callback) : m_callback(std::forward<TC>(callback))
explicit StreetTokensFilter(TC && callback) : m_callback(std::forward<TC>(callback))
{
}

Expand Down
3 changes: 2 additions & 1 deletion local_ads/local_ads_tests/statistics_tests.cpp
Expand Up @@ -9,7 +9,8 @@ namespace
class StatisticsGuard
{
public:
StatisticsGuard(local_ads::Statistics & statistics) : m_statistics(statistics) {}
explicit StatisticsGuard(local_ads::Statistics & statistics) : m_statistics(statistics) {}

~StatisticsGuard()
{
m_statistics.CleanupAfterTesting();
Expand Down
2 changes: 1 addition & 1 deletion map/map_tests/mwm_url_tests.cpp
Expand Up @@ -31,7 +31,7 @@ UserMark::Type const type = UserMark::Type::API;
class ApiTest
{
public:
ApiTest(string const & uriString)
explicit ApiTest(string const & uriString)
: m_fm(kFrameworkParams)
{
m_m = &m_fm.GetBookmarkManager();
Expand Down
2 changes: 1 addition & 1 deletion map/mwm_tests/mwm_foreach_test.cpp
Expand Up @@ -78,7 +78,7 @@ class IntersectCheck
bool m_isPrev, m_intersect;

public:
IntersectCheck(m2::RectD const & r)
explicit IntersectCheck(m2::RectD const & r)
: m_rect(r), m_isPrev(false), m_intersect(false)
{
}
Expand Down
2 changes: 1 addition & 1 deletion map/style_tests/style_symbols_consistency_test.cpp
Expand Up @@ -37,7 +37,7 @@ namespace
class SdfParsingDispatcher
{
public:
SdfParsingDispatcher(set<string> & symbols)
explicit SdfParsingDispatcher(set<string> & symbols)
: m_symbols(symbols)
{}

Expand Down
4 changes: 2 additions & 2 deletions map/user_mark.hpp
Expand Up @@ -132,15 +132,15 @@ class MyPositionMarkPoint : public StaticMarkPoint
class DebugMarkPoint : public UserMark
{
public:
DebugMarkPoint(m2::PointD const & ptOrg);
explicit DebugMarkPoint(m2::PointD const & ptOrg);

drape_ptr<SymbolNameZoomInfo> GetSymbolNames() const override;
};

class ColoredMarkPoint : public UserMark
{
public:
ColoredMarkPoint(m2::PointD const & ptOrg);
explicit ColoredMarkPoint(m2::PointD const & ptOrg);

void SetColor(dp::Color const & color);
void SetRadius(float radius);
Expand Down
Expand Up @@ -47,7 +47,7 @@ class TrafficDrawerDelegate : public TrafficDrawerDelegateBase
static constexpr char const * kGoldenLineId = "goldenPath";

public:
TrafficDrawerDelegate(Framework & framework)
explicit TrafficDrawerDelegate(Framework & framework)
: m_framework(framework)
, m_drapeApi(m_framework.GetDrapeApi())
, m_bm(framework.GetBookmarkManager())
Expand Down Expand Up @@ -122,7 +122,7 @@ bool PointsMatch(m2::PointD const & a, m2::PointD const & b)
class PointsControllerDelegate : public PointsControllerDelegateBase
{
public:
PointsControllerDelegate(Framework & framework)
explicit PointsControllerDelegate(Framework & framework)
: m_framework(framework)
, m_dataSource(framework.GetDataSource())
, m_roadGraph(m_dataSource, routing::IRoadGraph::Mode::ObeyOnewayTag,
Expand Down
2 changes: 1 addition & 1 deletion platform/mwm_traits.hpp
Expand Up @@ -41,7 +41,7 @@ class MwmTraits
Unknown
};

MwmTraits(MwmVersion const & version);
explicit MwmTraits(MwmVersion const & version);

SearchIndexFormat GetSearchIndexFormat() const;

Expand Down
15 changes: 9 additions & 6 deletions platform/platform_android.cpp
Expand Up @@ -82,19 +82,22 @@ size_t GetSearchSources(string const & file, string const & searchScope,
#ifdef DEBUG
class DbgLogger
{
string const & m_file;
SourceT m_src;
public:
DbgLogger(string const & file) : m_file(file) {}
void SetSource(SourceT src) { m_src = src; }
explicit DbgLogger(string const & file) : m_file(file) {}

~DbgLogger()
{
LOG(LDEBUG, ("Source for file", m_file, "is", m_src));
}

void SetSource(SourceT src) { m_src = src; }

private:
string const & m_file;
SourceT m_src;
};
#endif

}
} // namespace

unique_ptr<ModelReader> Platform::GetReader(string const & file, string const & searchScope) const
{
Expand Down
2 changes: 1 addition & 1 deletion platform/platform_tests/measurement_tests.cpp
Expand Up @@ -15,7 +15,7 @@ struct ScopedSettings
ScopedSettings() { m_wasSet = Get(kMeasurementUnits, m_oldUnits); }

/// Saves/restores previous units and sets new units for a scope.
ScopedSettings(Units newUnits) : ScopedSettings()
explicit ScopedSettings(Units newUnits) : ScopedSettings()
{
Set(kMeasurementUnits, newUnits);
}
Expand Down
2 changes: 1 addition & 1 deletion platform/platform_tests_support/scoped_mwm.hpp
Expand Up @@ -15,7 +15,7 @@ class ScopedFile;
class ScopedMwm
{
public:
ScopedMwm(string const & relativePath);
explicit ScopedMwm(string const & relativePath);

string const & GetFullPath() const { return m_file.GetFullPath(); }

Expand Down
2 changes: 1 addition & 1 deletion platform/string_storage_base.hpp
Expand Up @@ -9,7 +9,7 @@ namespace platform
class StringStorageBase
{
public:
StringStorageBase(std::string const & path);
explicit StringStorageBase(std::string const & path);
void Save() const;
void Clear();
bool GetValue(std::string const & key, std::string & outValue) const;
Expand Down
2 changes: 1 addition & 1 deletion qt/qt_common/scale_slider.cpp
Expand Up @@ -20,7 +20,7 @@ namespace
class MyProxyStyle : public ProxyStyle
{
public:
MyProxyStyle(QStyle * parent) : ProxyStyle(parent) {}
explicit MyProxyStyle(QStyle * parent) : ProxyStyle(parent) {}

int styleHint(StyleHint hint, const QStyleOption * option, const QWidget * widget,
QStyleHintReturn * returnData) const override
Expand Down

0 comments on commit 1d0428d

Please sign in to comment.