Skip to content

[QUALITY] Fix clang-tidy & clangd warnings across headers and sources. #205

@oguztoraman

Description

@oguztoraman

Confirmation

Version Information

Libmagicxx Version: main

Description

Running ./scripts/workflows.sh -p clang-tidy-checks -c produces errors (treated as errors due to -warnings-as-errors) across 5 files. These need to be resolved to achieve a clean clang-tidy pass.

Example(s)

misc-include-cleaner (53 occurrences in sources/magic.cpp)

Missing direct includes for used standard library and project symbols:

sources/magic.cpp:233:43: error: no header providing "std::bitset" is directly included
sources/magic.cpp:331:32: error: no header providing "std::filesystem::path" is directly included
sources/magic.cpp:677:24: error: no header providing "std::optional" is directly included
sources/magic.cpp:1014:47: error: no header providing "Recognition::PathIsNotDirectory" is directly included

readability-uppercase-literal-suffix (22 occurrences)

Literal suffixes should be uppercase:

include/magicxx/magic.hpp:560:24: error: integer literal has suffix 'uz', which is not uppercase
include/magicxx/progress_tracker.hpp:127:58: error: integer literal has suffix 'u', which is not uppercase

modernize-use-scoped-lock (8 occurrences in progress_tracker.hpp)

Replace std::lock_guard with the modern std::scoped_lock:

include/magicxx/progress_tracker.hpp:151:9: error: use 'std::scoped_lock' instead of 'std::lock_guard'

google-explicit-constructor (8 occurrences in sources/magic.cpp)

Conversion operators missing explicit:

sources/magic.cpp:2157:9: error: 'operator int' must be marked explicit to avoid unintentional implicit conversions
sources/magic.cpp:2176:9: error: 'operator vector' must be marked explicit to avoid unintentional implicit conversions
sources/magic.cpp:2201:9: error: 'operator basic_string' must be marked explicit to avoid unintentional implicit conversions

How to Reproduce

./scripts/workflows.sh -p clang-tidy-checks -c

Exit code: 2.

Metadata

Metadata

Assignees

Labels

qualityCode quality or style improvements

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions