Skip to content

Commit

Permalink
Add identifer-naming checks (#902)
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui authored Feb 1, 2024
1 parent 937ed79 commit c1cd305
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ CheckOptions:
value: camelBack
- key: readability-identifier-naming.LocalVariableCase
value: camelBack
- key: readability-identifier-naming.MemberCase
value: camelBack

- key: readability-identifier-naming.MacroDefinitionCase
value: UPPER_CASE
Expand Down
8 changes: 4 additions & 4 deletions src/Git2/Exception.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ git_error_clear() {

Exception::Exception() {
if (const git_error* error = git_error_last(); error != nullptr) {
this->m_message += error->message;
this->m_category = static_cast<git_error_t>(error->klass);
this->msg += error->message;
this->cat = static_cast<git_error_t>(error->klass);
git_error_clear();
}
}

const char*
Exception::what() const noexcept {
return this->m_message.c_str();
return this->msg.c_str();
}
git_error_t
Exception::category() const noexcept {
return this->m_category;
return this->cat;
}

int
Expand Down
4 changes: 2 additions & 2 deletions src/Git2/Exception.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ struct Exception final : public std::exception {
Exception& operator=(Exception&&) noexcept = default;

private:
String m_message = "git2-cpp: ";
git_error_t m_category{ GIT_ERROR_NONE };
String msg = "git2-cpp: ";
git_error_t cat{ GIT_ERROR_NONE };
};

int git2Throw(int ret);
Expand Down
6 changes: 3 additions & 3 deletions src/Git2/Revparse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ namespace git2 {

git_object*
Revspec::from() const noexcept {
return this->from_;
return this->fromObj;
}

git_object*
Revspec::to() const noexcept {
return this->to_;
return this->toObj;
}

unsigned int
Revspec::mode() const noexcept {
return this->mode_;
return this->modeVal;
}

} // end namespace git2
10 changes: 5 additions & 5 deletions src/Git2/Revparse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ namespace git2 {

struct Revspec : public GlobalState {
private:
git_object* from_ = nullptr;
git_object* to_ = nullptr;
unsigned int mode_; // git_revparse_mode_t
git_object* fromObj = nullptr;
git_object* toObj = nullptr;
unsigned int modeVal; // git_revparse_mode_t

public:
/// Assembles a new revspec from the from/to components.
Revspec(git_object* fromObj, git_object* toObj, unsigned int mode)
: from_(fromObj), to_(toObj), mode_(mode) {}
Revspec(git_object* from, git_object* toO, unsigned int mode)
: fromObj(from), toObj(toO), modeVal(mode) {}
Revspec() = delete;
~Revspec() = default;

Expand Down
12 changes: 6 additions & 6 deletions src/TermColor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ struct ColorState {
void set(const ColorMode mode) noexcept {
switch (mode) {
case ColorMode::always:
should_color_ = true;
state = true;
return;
case ColorMode::automatic:
should_color_ = isTerm();
state = isTerm();
return;
case ColorMode::never:
should_color_ = false;
state = false;
return;
}
}
inline bool shouldColor() const noexcept {
return should_color_;
return state;
}

static ColorState& instance() noexcept {
Expand All @@ -56,13 +56,13 @@ struct ColorState {

private:
// default: automatic
bool should_color_;
bool state;

ColorState() noexcept {
if (const char* color = std::getenv("POAC_TERM_COLOR")) {
set(getColorMode(color));
} else {
should_color_ = isTerm();
state = isTerm();
}
}
};
Expand Down

0 comments on commit c1cd305

Please sign in to comment.