Skip to content

Commit

Permalink
added more clang-tidy warnings and fixed some
Browse files Browse the repository at this point in the history
  • Loading branch information
antonvw committed Feb 8, 2025
1 parent c7dbb50 commit 240a30b
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 50 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
Checks:
'-*,
bugprone-branch-clone,
modernize-loop-convert,
modernize-macro-to-enum,
modernize-make-shared,
modernize-make-unique,
modernize-use-bool-literals,
Expand All @@ -11,6 +13,7 @@ Checks:
modernize-use-equals-delete,
modernize-use-nullptr,
modernize-use-override,
modernize-use-ranges
modernize-use-std-print,
modernize-use-starts-ends-with,
modernize-use-uncaught-exceptions,
Expand Down
18 changes: 4 additions & 14 deletions src/data/stc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,10 @@ bool wex::data::stc::inject_line() const
{
if (m_data.line() > 0)
{
int line;

if (m_stc->get_line_count() == LINE_COUNT_UNKNOWN)
{
line = m_data.line() - 1;
}
else if (m_data.line() - 1 >= m_stc->get_line_count())
{
line = m_stc->get_line_count() - 1;
}
else
{
line = m_data.line() - 1;
}
const int line = (m_stc->get_line_count() != LINE_COUNT_UNKNOWN &&
m_data.line() - 1 >= m_stc->get_line_count()) ?
m_stc->get_line_count() - 1 :
m_data.line() - 1;

m_stc->goto_line(line);

Expand Down
6 changes: 1 addition & 5 deletions src/ex/variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,7 @@ void wex::variable::set_argument(const std::string& val)

void wex::variable::set_ask_for_input(bool value)
{
if (!value)
{
m_ask_for_input = value;
}
else if (is_input() && m_type != input_t::INPUT_ONCE)
if (!value || is_input() && m_type != input_t::INPUT_ONCE)
{
m_ask_for_input = value;
}
Expand Down
12 changes: 4 additions & 8 deletions src/ex/vi/commands-other.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ size_t fold(wex::syntax::stc* stc, const std::string& command)
case 'c':
case 'o':
if (
stc->GetFoldExpanded(line_to_fold) &&
boost::algorithm::trim_copy(command) == "zc")
{
stc->ToggleFold(line_to_fold);
}
else if (
!stc->GetFoldExpanded(line_to_fold) &&
boost::algorithm::trim_copy(command) == "zo")
(stc->GetFoldExpanded(line_to_fold) &&
boost::algorithm::trim_copy(command) == "zc") ||
(!stc->GetFoldExpanded(line_to_fold) &&
boost::algorithm::trim_copy(command) == "zo"))
{
stc->ToggleFold(line_to_fold);
}
Expand Down
9 changes: 3 additions & 6 deletions src/ex/vi/mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,12 +405,9 @@ bool wex::vi_mode::transition(std::string& command)
break;

case state_t::VISUAL_LINE:
if (m_vi->get_stc()->SelectionIsRectangle())
{
m_vi->get_stc()->Home();
m_vi->get_stc()->LineDownExtend();
}
else if (m_vi->get_stc()->GetSelectedText().empty())
if (
m_vi->get_stc()->SelectionIsRectangle() ||
m_vi->get_stc()->GetSelectedText().empty())
{
m_vi->get_stc()->Home();
m_vi->get_stc()->LineDownExtend();
Expand Down
7 changes: 2 additions & 5 deletions src/stc/auto-indent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Name: stc/auto-indent.cpp
// Purpose: Implementation of class wex::auto_indent
// Author: Anton van Wezenbeek
// Copyright: (c) 2021-2024 Anton van Wezenbeek
// Copyright: (c) 2021-2025 Anton van Wezenbeek
////////////////////////////////////////////////////////////////////////////////

#include <wex/core/config.h>
Expand Down Expand Up @@ -90,12 +90,9 @@ bool wex::auto_indent::is_indentable(int c) const
break;

case wxSTC_EOL_CRLF:
is_nl = (c == '\n');
break; // so ignore first \r

case wxSTC_EOL_LF:
is_nl = (c == '\n');
break;
break; // so ignore first \r for CRLF
}

return is_nl;
Expand Down
9 changes: 2 additions & 7 deletions src/syntax/stc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,8 @@ void wex::syntax::stc::fold_all()

while (line < get_line_count())
{
if (const auto level = GetFoldLevel(line);
xml && (level == wxSTC_FOLDLEVELBASE + wxSTC_FOLDLEVELHEADERFLAG))
{
line++;
}
else if (const auto last_child_line = GetLastChild(line, level);
last_child_line > line + 1)
if (const auto last_child_line = GetLastChild(line, GetFoldLevel(line));
last_child_line > line + 1)
{
if (GetFoldExpanded(line))
{
Expand Down
8 changes: 3 additions & 5 deletions src/ui/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,18 +80,16 @@ bool no_value(wex::item::type_t t)
{
switch (t)
{
// Not yet implemented or no value
case item::BUTTON:
case item::CHECKLISTBOX_BOOL:
case item::COMMANDLINKBUTTON:
case item::GROUP:
case item::RADIOBOX:
case item::STATICBOX:
case item::STATICLINE:
case item::STATICTEXT:
break;

case item::CHECKLISTBOX_BOOL:
case item::RADIOBOX:
case item::USER:
// Not yet implemented
break;

default:
Expand Down

0 comments on commit 240a30b

Please sign in to comment.