diff --git a/logdoctor/games/crisscross/game.cpp b/logdoctor/games/crisscross/game.cpp index 4fea9da4..77debc3e 100644 --- a/logdoctor/games/crisscross/game.cpp +++ b/logdoctor/games/crisscross/game.cpp @@ -189,7 +189,7 @@ bool CrissCross::checkVictory() streak = 0; for ( const auto& index : sequence ) { if ( this->board[ index ] == this->p_turn ) { - streak ++; + ++streak; this->victory_sequence.push_back( index ); } else { break; @@ -210,7 +210,7 @@ void CrissCross::victory() { // disable all buttons except the victory sequence ones bool disable{ true }; - for ( unsigned i=0; i<9; i++ ) { + for ( unsigned i=0; i<9; ++i ) { disable |= true; for ( const auto& j : this->victory_sequence ) { if ( i == j ) { @@ -252,7 +252,7 @@ bool CrissCross::gameDraw() const unsigned empty_tiles{ 9 }; for ( const auto& tile : this->board ) { if ( tile > 0 ) { - empty_tiles --; + -- empty_tiles; } } if ( empty_tiles == 0 ) { @@ -290,7 +290,7 @@ void CrissCross::AI_playTurn() void CrissCross::AI_updateWeights() { // reset the weights - for ( size_t i{0ul}; i<9ul; i++ ) { + for ( size_t i{0ul}; i<9ul; ++i ) { this->board_weights[ i ] = 0; } // calculate the new weights @@ -303,9 +303,9 @@ void CrissCross::AI_updateWeights() // check the tiles in the sequence for ( const auto index : sequence ) { if ( this->board[ index ] == this->p_turn ) { - win_streak ++; + ++ win_streak; } else if ( this->board[ index ] > 0 ) { - lose_streak ++; + ++ lose_streak; } else { empty_tiles.emplace_back( std::move(index) ); } @@ -341,7 +341,7 @@ unsigned CrissCross::AI_makeChoice() const // lighter weight ; }*/ - index ++; + ++ index; } // decide the movement (or better, randomly pick one) unsigned next_move; diff --git a/logdoctor/games/snake/game.cpp b/logdoctor/games/snake/game.cpp index be932f4a..7b9fcedd 100644 --- a/logdoctor/games/snake/game.cpp +++ b/logdoctor/games/snake/game.cpp @@ -185,17 +185,17 @@ void SnakeGame::newSnake_() case Direction::UP: case Direction::DOWN: if ( rnd ) { - head_x ++; + ++ head_x; } else { - head_x --; + -- head_x; } break; case Direction::LEFT: case Direction::RIGHT: if ( rnd ) { - head_y ++; + ++ head_y; } else { - head_y --; + -- head_y; } break; default: @@ -272,7 +272,7 @@ void SnakeGame::processGameLogic() this->moving_countdown = this->moving_rate; } } else if ( this->game_mode == GameMode::Hunt ) { - this->moving_countdown --; + -- this->moving_countdown; if ( this->moving_countdown == 0u ) { this->moving_countdown = this->moving_rate; this->food.move( this->snake ); @@ -327,16 +327,16 @@ void SnakeGame::checkCollision( Snake& snake, Snake& adv_snake, const bool is_ad unsigned x_, y_; switch ( snake.direction() ) { case Direction::UP: - y--; + --y; break; case Direction::DOWN: - y++; + ++y; break; case Direction::LEFT: - x--; + --x; break; case Direction::RIGHT: - x++; + ++x; break; default: // should be unreachable @@ -348,16 +348,16 @@ void SnakeGame::checkCollision( Snake& snake, Snake& adv_snake, const bool is_ad y_ = adv_snake.front().y; switch ( adv_snake.direction() ) { case Direction::UP: - y_--; + --y_; break; case Direction::DOWN: - y_++; + ++y_; break; case Direction::LEFT: - x_--; + --x_; break; case Direction::RIGHT: - x_++; + ++x_; break; default: // should be unreachable diff --git a/logdoctor/games/snake/snake.cpp b/logdoctor/games/snake/snake.cpp index 83317e24..c63e7a1c 100644 --- a/logdoctor/games/snake/snake.cpp +++ b/logdoctor/games/snake/snake.cpp @@ -40,13 +40,13 @@ bool Snake::inTile( const unsigned x, const unsigned y, const bool avoid_tail ) size_t i{ 0 }; size_t max{ this->size()-1ul }; if ( !avoid_tail ) { - max ++; + ++ max; } for ( auto bp{ this->cbegin() }; bp != this->cend(); ++bp ) { if ( bp->x == x && bp->y == y ) { return true; } - i++; + ++i; if ( i >= max ) { break; } @@ -81,16 +81,16 @@ void Snake::grow( const bool is_borning ) // one tile behind switch ( d ) { case Direction::UP: - y ++; + ++ y; break; case Direction::DOWN: - y --; + -- y; break; case Direction::LEFT: - x ++; + ++ x; break; case Direction::RIGHT: - x --; + -- x; break; default: // should be unreachable @@ -366,7 +366,7 @@ void Snake::update( QGraphicsScene* field_scene, const bool dry , const bool is_ throw("Unexpected direction: "+std::to_string(bp->direction)); } prev_body_d = bp->direction; - i++; + ++i; } } @@ -399,7 +399,7 @@ void Snake::move( const Snake& adv_snake, const unsigned food_x, const unsigned this->updateFieldMap( adv_snake, food_x, food_y ); - for ( size_t i{0}; i<4ul; i++ ) { + for ( size_t i{0}; i<4ul; ++i ) { this->collectData( dataset.at(i), classes.at(i), adv_snake, food_x, food_y ); } @@ -415,10 +415,10 @@ Direction Snake::predictDirection( const std::array,4>& data Direction class_label; // process data - for ( size_t i{0}; i<4ul; i++ ) { + for ( size_t i{0}; i<4ul; ++i ) { const std::array& d = data.at(i); float& r = results[i]; - for ( size_t j{0}; j<7ul; j++ ) { + for ( size_t j{0}; j<7ul; ++j ) { r += d.at(j) * weights.at(j); } } @@ -434,12 +434,12 @@ Direction Snake::predictDirection( const std::array,4>& data } } if ( max != min ) { - for ( size_t i{0}; i<4ul; i++ ) { + for ( size_t i{0}; i<4ul; ++i ) { results[i] = (results[i]-min) / (max-min); } } else { keep_current |= true; - for ( size_t i{0}; i<4ul; i++ ) { + for ( size_t i{0}; i<4ul; ++i ) { results[i] = 0.f; } } @@ -449,7 +449,7 @@ Direction Snake::predictDirection( const std::array,4>& data class_label = this->head_direction; } else { max = 0.f; - for ( size_t i{0}; i<4ul; i++ ) { + for ( size_t i{0}; i<4ul; ++i ) { if ( results[i] > max ) { class_label = classes.at(i); max = results[i]; @@ -731,8 +731,8 @@ void Snake::collectData( std::array& data, const Direction& direction, void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, const unsigned& food_y ) { // reset to default state - for ( size_t x{0}; x<16ul; x++ ) { - for ( size_t y{0}; y<16ul; y++ ) { + for ( size_t x{0}; x<16ul; ++x ) { + for ( size_t y{0}; y<16ul; ++y ) { Tile& t = this->field_map.at(x).at(y); t.entity = Entity::N; t.s_index = 0u; @@ -746,7 +746,7 @@ void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, cons Tile& t = this->field_map.at(bp->x).at(bp->y); t.entity = Entity::S; t.s_index = i; - i--; + --i; } // update adversary i = static_cast( adv_snake.size() ); @@ -754,7 +754,7 @@ void Snake::updateFieldMap( const Snake& adv_snake, const unsigned& food_x, cons Tile& t = this->field_map.at(bp.x).at(bp.y); t.entity = Entity::A; t.s_index = i; - i--; + --i; } } @@ -836,7 +836,7 @@ std::array Snake::checkAround( const Direction& direction, const uns } unsigned x_, y_; - for ( size_t i{0}; i<8ul; i++ ) { + for ( size_t i{0}; i<8ul; ++i ) { x_ = x; x_ += x_pattern.at(i); y_ = y; @@ -1104,7 +1104,7 @@ unsigned Snake::isDeadHole( const unsigned start_x, const unsigned start_y, cons result = true; break; } else { - steps ++; + ++ steps; if ( steps >= max_steps ) { break; } @@ -1121,7 +1121,7 @@ unsigned Snake::isDeadHole( const unsigned start_x, const unsigned start_y, cons if ( !result ) { steps = 0; } - i ++; + ++ i; if ( i == 2u ) { break; } diff --git a/logdoctor/mainwindow.cpp b/logdoctor/mainwindow.cpp index 27364422..ab96ec82 100644 --- a/logdoctor/mainwindow.cpp +++ b/logdoctor/mainwindow.cpp @@ -382,7 +382,7 @@ void MainWindow::readConfigs() std::vector aux, configs; try { // reset the lists when a config file is found - for ( unsigned w=APACHE_ID; w<=IIS_ID; w++ ) { + for ( unsigned w=APACHE_ID; w<=IIS_ID; ++w ) { for ( const int& f : {11,12,20,21} ) { this->craplog.setWarnlist( w, f, {} ); } @@ -952,7 +952,7 @@ void MainWindow::backupDatabase() const } if ( proceed ) { // cascade rename - for ( int n=this->db_backups_number-1; n>=0; n-- ) { + for ( int n=this->db_backups_number-1; n>=0; --n ) { path = this->db_data_path+"/backups/collection.db."+std::to_string( n ); if ( std::filesystem::exists( path ) ) { new_path = this->db_data_path+"/backups/collection.db."+std::to_string( n+1 ); @@ -2673,9 +2673,9 @@ void MainWindow::on_listLogFiles_itemChanged(QTreeWidgetItem *item, int column) QTreeWidgetItemIterator i(this->ui->listLogFiles); while ( *i ) { if ( (*i)->checkState(0) == Qt::CheckState::Checked ) { - n_checked++; + ++ n_checked; } - ++i; + ++ i; } if ( n_checked == 0ul ) { this->ui->checkBox_LogFiles_CheckAll->setCheckState(Qt::CheckState::Unchecked); @@ -4362,7 +4362,7 @@ void MainWindow::refreshChartsPreview() return (rand()%10 > 8) ? rand()%100 : (rand()%10 > 6) ? rand()%50 : rand()%30; }; int aux, max{0}; - for ( int i{0}; i<24; i++ ) { + for ( int i{0}; i<24; ++i ) { aux = random_value(); *bars_1 << aux; if ( aux > max ) { @@ -4772,7 +4772,7 @@ void MainWindow::on_list_ConfApache_Warnlist_List_itemSelectionChanged() this->ui->button_ConfApache_Warnlist_Up->setEnabled( false ); this->ui->button_ConfApache_Warnlist_Down->setEnabled( false ); } else { - for ( int i{0}; i<=max; i++ ) { + for ( int i{0}; i<=max; ++i ) { if ( this->ui->list_ConfApache_Warnlist_List->item(i) == item ) { if ( i == 0 ) { this->ui->button_ConfApache_Warnlist_Up->setEnabled( false ); @@ -4919,7 +4919,7 @@ void MainWindow::on_list_ConfApache_Blacklist_List_itemSelectionChanged() this->ui->button_ConfApache_Blacklist_Up->setEnabled( false ); this->ui->button_ConfApache_Blacklist_Down->setEnabled( false ); } else { - for ( int i{0}; i<=max; i++ ) { + for ( int i{0}; i<=max; ++i ) { if ( this->ui->list_ConfApache_Blacklist_List->item(i) == item ) { if ( i == 0 ) { this->ui->button_ConfApache_Blacklist_Up->setEnabled( false ); @@ -5143,7 +5143,7 @@ void MainWindow::on_list_ConfNginx_Warnlist_List_itemSelectionChanged() this->ui->button_ConfNginx_Warnlist_Up->setEnabled( false ); this->ui->button_ConfNginx_Warnlist_Down->setEnabled( false ); } else { - for ( int i{0}; i<=max; i++ ) { + for ( int i{0}; i<=max; ++i ) { if ( this->ui->list_ConfNginx_Warnlist_List->item(i) == item ) { if ( i == 0 ) { this->ui->button_ConfNginx_Warnlist_Up->setEnabled( false ); @@ -5290,7 +5290,7 @@ void MainWindow::on_list_ConfNginx_Blacklist_List_itemSelectionChanged() this->ui->button_ConfNginx_Blacklist_Up->setEnabled( false ); this->ui->button_ConfNginx_Blacklist_Down->setEnabled( false ); } else { - for ( int i{0}; i<=max; i++ ) { + for ( int i{0}; i<=max; ++i ) { if ( this->ui->list_ConfNginx_Blacklist_List->item(i) == item ) { if ( i == 0 ) { this->ui->button_ConfNginx_Blacklist_Up->setEnabled( false ); @@ -5577,7 +5577,7 @@ void MainWindow::on_list_ConfIis_Warnlist_List_itemSelectionChanged() this->ui->button_ConfIis_Warnlist_Up->setEnabled( false ); this->ui->button_ConfIis_Warnlist_Down->setEnabled( false ); } else { - for ( int i{0}; i<=max; i++ ) { + for ( int i{0}; i<=max; ++i ) { if ( this->ui->list_ConfIis_Warnlist_List->item(i) == item ) { if ( i == 0 ) { this->ui->button_ConfIis_Warnlist_Up->setEnabled( false ); @@ -5724,7 +5724,7 @@ void MainWindow::on_list_ConfIis_Blacklist_List_itemSelectionChanged() this->ui->button_ConfIis_Blacklist_Up->setEnabled( false ); this->ui->button_ConfIis_Blacklist_Down->setEnabled( false ); } else { - for ( int i{0}; i<=max; i++ ) { + for ( int i{0}; i<=max; ++i ) { if ( this->ui->list_ConfIis_Blacklist_List->item(i) == item ) { if ( i == 0 ) { this->ui->button_ConfIis_Blacklist_Up->setEnabled( false ); diff --git a/logdoctor/modules/craplog/craplog.cpp b/logdoctor/modules/craplog/craplog.cpp index 0285da1a..e7399881 100644 --- a/logdoctor/modules/craplog/craplog.cpp +++ b/logdoctor/modules/craplog/craplog.cpp @@ -33,7 +33,7 @@ Craplog::Craplog() //// INITIALIZATION //// //////////////////////// // blacklists / whitelists - for ( unsigned i{APACHE_ID}; i<=IIS_ID; i++ ) { + for ( unsigned i{APACHE_ID}; i<=IIS_ID; ++i ) { this->warnlists.emplace( i, std::unordered_map(4) ); this->blacklists.emplace( i, std::unordered_map(1) ); // default data @@ -185,7 +185,7 @@ void Craplog::blacklistRemove( const unsigned& web_server_id, const int& log_fie auto& list = this->blacklists.at( web_server_id ).at( log_field_id ).list; // move the item to the end, then pop it const size_t max{ list.size()-1ul }; - for ( size_t i{0}; iwarnlists.at( web_server_id ).at( log_field_id ).list; // move the item to the end, then pop it const size_t max{ list.size()-1ul }; - for ( size_t i{0}; iblacklists.at( web_server_id ).at( log_field_id ).list; size_t i{ 1 }; const size_t max{ list.size() }; - for ( ; iwarnlists.at( web_server_id ).at( log_field_id ).list; size_t i{ 1 }; const size_t max{ list.size() }; - for ( ; iblacklists.at( web_server_id ).at( log_field_id ).list; size_t i{ 0 }; const size_t max{ list.size()-1ul }; - for ( ; iwarnlists.at( web_server_id ).at( log_field_id ).list; size_t i{ 0 }; const size_t max{ list.size()-1ul }; - for ( ; i" || aux_fld == "<" ) { aux_fld += f_str.at( aux+1 ); - aux_stop ++; + ++ aux_stop; } // check if the module is valid if ( f_map.find( aux_fld ) != f_map.end() ) { @@ -566,7 +566,7 @@ LogsFormat FormatOps::processApacheFormatString( const std::string& f_str ) cons // append the field fields.push_back( cur_fld ); - n_fld++; + ++ n_fld; } return LogsFormat( @@ -582,7 +582,7 @@ QString FormatOps::getApacheLogSample( const LogsFormat& log_format ) const // append the initial characters sample += QString::fromStdString( log_format.initial ); - for ( size_t i{0ul}; i& lines, const LogsFormat& for ( const std::string& line : lines ) { // scan the given lines if ( deepTypeCheck( line, format ) ) { - n_access++; + ++ n_access; } else { - n_other++; + ++ n_other; } } diff --git a/logdoctor/modules/craplog/modules/workers/impl/loglinedata.cpp b/logdoctor/modules/craplog/modules/workers/impl/loglinedata.cpp index 627da13e..7cf29379 100644 --- a/logdoctor/modules/craplog/modules/workers/impl/loglinedata.cpp +++ b/logdoctor/modules/craplog/modules/workers/impl/loglinedata.cpp @@ -256,7 +256,7 @@ LogLineData::LogLineData(const std::string& line, const LogsFormat& logs_format) // update the stop for the next start stop += sep_size; - sep_i++; + ++sep_i; if ( stop > line_size ) { // this was the final separator break; diff --git a/logdoctor/modules/craplog/modules/workers/parser.cpp b/logdoctor/modules/craplog/modules/workers/parser.cpp index 16629e1c..04879184 100644 --- a/logdoctor/modules/craplog/modules/workers/parser.cpp +++ b/logdoctor/modules/craplog/modules/workers/parser.cpp @@ -193,7 +193,7 @@ void CraplogParser::parseLogLines() const auto parseLine = [this]( const std::string& line, const LogsFormat& logs_format ) { this->data_collection.emplace_back( LogLineData(line, logs_format) ); this->parsed_size += line.size(); - this->parsed_lines ++; + ++ this->parsed_lines; }; @@ -219,10 +219,10 @@ void CraplogParser::parseLogLines() const size_t send_gap{ real_lines>1000ul ? real_lines/100 : real_lines>100ul ? real_lines/10 : 10 }; const LogsFormat& lf {this->logs_format}; this->data_collection.reserve( real_lines ); - for ( size_t i{0ul}; ilogs_lines.at( i ); - for ( size_t n{0ul}; nlogs_lines.at( i ); } parseLine( line, lf ); diff --git a/logdoctor/modules/crapview/crapview.cpp b/logdoctor/modules/crapview/crapview.cpp index f7550eb2..0ba90a42 100644 --- a/logdoctor/modules/crapview/crapview.cpp +++ b/logdoctor/modules/crapview/crapview.cpp @@ -153,7 +153,7 @@ void Crapview::sliceClicked( QPieSlice* slice ) void Crapview::updateWarn( QTableWidget* table , const QString& web_server ) const { std::vector> updates; // { (rowid, warn) } - for ( int i{0}; irowCount(); i++ ) { + for ( int i{0}; irowCount(); ++i ) { QTableWidgetItem* item = table->item( i, 0 ); if ( item->checkState() == Qt::CheckState::Checked && item->text() == TR::tr( BOOLS__FALSE.c_str() ) ) { // remove warning @@ -188,13 +188,13 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C int norm_count, warn_count, sum_count, max_count=0, n_rows=0; if ( hour.isEmpty() ) { // entire day - for ( int i{0}; i<6; i++ ) { + for ( int i{0}; i<6; ++i ) { sets.push_back( std::vector() ); sets.back().push_back( new QBarSet("") ); sets.back().push_back( new QBarSet("") ); } - for ( size_t h{0}; h<24ul; h++ ) { - for ( size_t m{0}; m<6ul; m++ ) { + for ( size_t h{0}; h<24ul; ++h ) { + for ( size_t m{0}; m<6ul; ++m ) { const auto& data{ items.at( h ).at( m ) }; norm_count = warn_count = 0; for ( const std::vector& line : data ) { @@ -210,7 +210,7 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); int col{ 3 }; const size_t max{ line.size() }; - for ( size_t i{7ul}; i= 12) && !line.at(i).isEmpty() ) { itm = new QTableWidgetItem(); @@ -219,14 +219,14 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C itm = new QTableWidgetItem( line.at( i ) ); } table->setItem( n_rows, col, itm ); - col ++; + ++ col; } if ( line.at( 0ul ) == "0" ) { - norm_count ++; + ++ norm_count; } else { - warn_count ++; + ++ warn_count; } - n_rows ++; + ++ n_rows; } sets.at( m ).at( 0ul )->append( norm_count ); sets.at( m ).at( 1ul )->append( warn_count ); @@ -239,13 +239,13 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C date = PrintSec::printableDate( year, this->getMonthNumber( month ), day ); } else { // 1 hour - for ( int i{0}; i<10; i++ ) { + for ( int i{0}; i<10; ++i ) { sets.push_back( std::vector() ); sets.back().push_back( new QBarSet("") ); sets.back().push_back( new QBarSet("") ); } - for ( size_t g{0ul}; g<6ul; g++ ) { - for ( size_t m{0ul}; m<10ul; m++ ) { + for ( size_t g{0ul}; g<6ul; ++g ) { + for ( size_t m{0ul}; m<10ul; ++m ) { const auto& data{ items.at( g ).at( m ) }; norm_count = warn_count = 0; for ( const std::vector& line : data ) { @@ -260,13 +260,13 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C } table->setItem( n_rows, 1, new QTableWidgetItem( PrintSec::printableDate( line.at( 1 ).toInt(), line.at( 2 ).toInt(), line.at( 3 ).toInt() ))); table->setItem( n_rows, 2, new QTableWidgetItem( PrintSec::printableTime( line.at( 4 ).toInt(), line.at( 5 ).toInt(), line.at( 6 ).toInt() ))); - for ( size_t i{7ul}; isetItem( n_rows, i-4, new QTableWidgetItem( line.at( i ) )); } if ( line.at( 0ul ) == "0" ) { - norm_count ++; + ++ norm_count; } else { - warn_count ++; + ++ warn_count; } } sets.at( m ).at( 0ul )->append( norm_count ); @@ -286,10 +286,10 @@ void Crapview::drawWarn( QTableWidget* table, QChartView* chart, const QChart::C //QColor cols[] = {QColor(18,175,194), QColor(237,80,61)}; std::vector b_series; const size_t max{ sets.size() }; - for ( size_t i{0}; isetColor( cols[ w ] ); b_series.at( i )->append( b ); @@ -374,7 +374,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart:: QDateTime dt; std::vector data; for ( const auto& item : items ) { - i++; + ++i; // append a value to the chart aux_time = std::get<0>(item); data = std::get<1>(item); @@ -401,7 +401,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart:: if ( first_count ) { first_count &= false; } else { - count ++; + ++ count; } value += aux_value; if ( i == max_i ) { @@ -426,7 +426,7 @@ void Crapview::drawSpeed( QTableWidget* table, QChartView* chart, const QChart:: table->setItem( n_rows, 5, new QTableWidgetItem( data.at(5ul) )); dt = QDateTime::fromMSecsSinceEpoch( aux_time ); table->setItem( n_rows, 6, new QTableWidgetItem( dt.time().toString("hh:mm:ss") )); - n_rows ++; + ++ n_rows; } } table->verticalHeader()->setVisible( false ); @@ -527,7 +527,7 @@ void Crapview::drawCount( QTableWidget* table, QChartView* chart, const QChart:: ic->setData( Qt::DisplayRole, count ); table->setItem( n_rows, 0, ic ); table->setItem( n_rows, 1, new QTableWidgetItem( item )); - n_rows ++; + ++ n_rows; } table->verticalHeader()->setVisible( false ); @@ -594,7 +594,7 @@ void Crapview::drawDay( QChartView* chart, const QChart::ChartTheme& theme, cons // build the bars upon data int count, max_count{0}; - for ( size_t h{0ul}; h<24ul; h++ ) { + for ( size_t h{0ul}; h<24ul; ++h ) { auto& data = items.at( h ); count = data.at( 0ul ); *b_10 << count; @@ -823,7 +823,7 @@ bool Crapview::calcGlobals( std::vector>& recur_list // compose the results // max request elements - for ( size_t i{0}; i<4ul; i++ ) { + for ( size_t i{0}; i<4ul; ++i ) { unsigned max{ 0 }; QString max_str{ "-" }; const auto& aux{ recurs.at( i ) }; diff --git a/logdoctor/modules/crapview/modules/filters.cpp b/logdoctor/modules/crapview/modules/filters.cpp index a51d7fea..cc2c0790 100644 --- a/logdoctor/modules/crapview/modules/filters.cpp +++ b/logdoctor/modules/crapview/modules/filters.cpp @@ -115,18 +115,18 @@ std::optional parseNumericFilter( const QString& filter_str ) size_t i{ 0ul }; const size_t max{ str.size() }; if ( char c=str.at(i); c == '=' || c == '!' || c == '<' || c == '>' ) { - i ++; + ++i; if ( i >= max ) { return result; } if ( str.at(i) == '=' ) { - i ++; + ++i; if ( i >= max ) { return result; } } if ( str.at(i) == ' ' ) { - i ++; + ++i; if ( i >= max ) { return result; } diff --git a/logdoctor/modules/crapview/modules/query.cpp b/logdoctor/modules/crapview/modules/query.cpp index 077b60be..6f0ac137 100644 --- a/logdoctor/modules/crapview/modules/query.cpp +++ b/logdoctor/modules/crapview/modules/query.cpp @@ -43,7 +43,7 @@ int DbQuery::getMinuteGap( const int minute, const int gap ) m = gap * n; break; } - n++; + ++n; } return m; } @@ -95,7 +95,7 @@ int DbQuery::countDays( const int from_year, const int from_month, const int fro n_days += to_day - from_day + 1; } else { n_days += getMonthDays( from_year, from_month ) - from_day; // first month's days - for ( int month=from_month+1; month& result, const QS if ( hour_.isEmpty() ) { // entire day items.reserve( 24 ); - for ( size_t h{0}; h<24ul; h++ ) { + for ( size_t h{0}; h<24ul; ++h ) { items.push_back( std::vector>>() ); auto& aux{ items.at( h ) }; aux.reserve( 6 ); @@ -472,10 +472,10 @@ void DbQuery::getWarnCounts( std::optional& result, const QS while ( query.next() ) { std::vector aux; aux.reserve( 20 ); - for ( int i{1}; i<13; i++ ) { + for ( int i{1}; i<13; ++i ) { aux.push_back( query.value( i ).toString() ); } - for ( int i{19}; i>12; i-- ) { + for ( int i{19}; i>12; --i ) { aux.push_back( query.value( i ).toString() ); } aux.push_back( query.value( 0 ).toString() ); @@ -494,11 +494,11 @@ void DbQuery::getWarnCounts( std::optional& result, const QS } else { // 1 hour items.reserve( 6 ); - for ( size_t g{0}; g<6ul; g++ ) { + for ( size_t g{0}; g<6ul; ++g ) { items.push_back( std::vector>>() ); auto& aux{ items.at( g ) }; aux.reserve( 10ul ); - for ( int m{0}; m<10; m++ ) { + for ( int m{0}; m<10; ++m ) { aux.push_back( std::vector>() ); } } @@ -515,10 +515,10 @@ void DbQuery::getWarnCounts( std::optional& result, const QS while ( query.next() ) { std::vector aux; aux.reserve( 20 ); - for ( int i{1}; i<13; i++ ) { + for ( int i{1}; i<13; ++i ) { aux.push_back( query.value( i ).toString() ); } - for ( int i{19}; i>12; i-- ) { + for ( int i{19}; i>12; --i ) { aux.push_back( query.value( i ).toString() ); } aux.push_back( query.value( 0 ).toString() ); @@ -714,9 +714,9 @@ void DbQuery::getSpeedData( std::optional& result, const QS if ( aux_hour == hour ) { h=hour; m=minute; s=second-1; if ( s < 0 ) { - s=59; m--; + s=59; --m; if ( m < 0 ) { - m=59; h--; + m=59; --h; if ( h < 0 ) { h=m=s=0; } @@ -737,9 +737,9 @@ void DbQuery::getSpeedData( std::optional& result, const QS // append the second after the last one found, if it is not equal to the next h=hour; m=minute; s=second+1; if ( s > 59 ) { - s=0; m++; + s=0; ++m; if ( m > 59 ) { - m=0; h++; + m=0; ++h; if ( h > 23 ) { h=23;m=59;s=59; } @@ -759,9 +759,9 @@ void DbQuery::getSpeedData( std::optional& result, const QS // append the prev as zero h=hour; m=minute; s=second-1; if ( s < 0 ) { - s=59; m--; + s=59; --m; if ( m < 0 ) { - m=59; h--; + m=59; --h; if ( h < 0 ) { h=m=s=0; } @@ -781,9 +781,9 @@ void DbQuery::getSpeedData( std::optional& result, const QS // append the next as zero h=hour; m=minute; s=second+1; if ( s > 59 ) { - s=0; m++; + s=0; ++m; if ( m > 59 ) { - m=0; h++; + m=0; ++h; if ( h > 23 ) { h=23;m=59;s=59; } @@ -805,9 +805,9 @@ void DbQuery::getSpeedData( std::optional& result, const QS // append the second before the first found h=aux_hour; m=aux_minute; s=aux_second-1; if ( s < 0 ) { - s=59; m--; + s=59; --m; if ( m < 0 ) { - m=59; h--; + m=59; --h; if ( h < 0 ) { // abort h=m=s=0; @@ -840,9 +840,9 @@ void DbQuery::getSpeedData( std::optional& result, const QS // last one, append the prev h=hour; m=minute; s=second-1; if ( s < 0 ) { - s=59; m--; + s=59; --m; if ( m < 0 ) { - m=59; h--; + m=59; --h; if ( h < 0 ) { h=m=s=0; } @@ -862,9 +862,9 @@ void DbQuery::getSpeedData( std::optional& result, const QS // append 1 second after the last h=hour; m=minute; s=second+1; if ( s > 59 ) { - s=0; m++; + s=0; ++m; if ( m > 59 ) { - m=0; h++; + m=0; ++h; if ( h > 23 ) { h=23;m=59;s=59; } @@ -878,13 +878,13 @@ void DbQuery::getSpeedData( std::optional& result, const QS } } // append the last fictitious count - day ++; + ++ day; if ( day > getMonthDays( year, month ) ) { day = 1; - month ++; + ++ month; if ( month > 12 ) { month = 1; - year ++; + ++ year; } } time.setDate( QDate( year, month , day ) ); @@ -974,7 +974,7 @@ void DbQuery::getItemsCount( std::optional& result, const Q while ( query.next() ) { item = query.value(0).toString(); if ( ! item.isEmpty() ) { - aux_items[ item ] ++; + ++ aux_items[ item ]; } } } catch (...) { @@ -1138,9 +1138,9 @@ void DbQuery::getDaytimeCounts( std::optional& result, const hour = query.value(1).toInt(); minute = query.value(2).toInt(); // increase the count - data.at( hour ).at( getMinuteGap( minute ) ) ++; + ++ data.at( hour ).at( getMinuteGap( minute ) ); // append the day as newly found if not found yet - days_l[ day ] ++; + ++ days_l[ day ]; } n_days += static_cast(days_l.size()); } catch (...) { @@ -1152,7 +1152,7 @@ void DbQuery::getDaytimeCounts( std::optional& result, const } else { - for ( int m=1; m<=n_months; m++ ) { + for ( int m=1; m<=n_months; ++m ) { stmt = QString("SELECT \"day\", \"hour\", \"minute\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3") .arg( web_server ) .arg( year ).arg( month ); @@ -1217,15 +1217,15 @@ void DbQuery::getDaytimeCounts( std::optional& result, const hour = query.value(1).toInt(); minute = query.value(2).toInt(); // increase the count - data.at( hour ).at( getMinuteGap( minute ) ) ++; + ++ data.at( hour ).at( getMinuteGap( minute ) ); // append the day as newly found if not found yet - days_l[ day ] ++; + ++ days_l[ day ]; } n_days += static_cast(days_l.size()); - month ++; + ++ month; if ( month > 12 ) { month = 1; - year ++; + ++ year; } } catch (...) { // something failed @@ -1245,7 +1245,7 @@ void DbQuery::getDaytimeCounts( std::optional& result, const if ( count > 0 ) { count /= n_days; if ( count == 0 ) { - count++; + ++ count; } } } @@ -1404,7 +1404,7 @@ void DbQuery::getRelationalCountsDay( std::optional& result } else if ( ! query.last() ) { // no result found, fill with 0 values - for ( int h{0}; h<24; h++ ) { + for ( int h{0}; h<24; ++h ) { for ( int m{0}; m<60; m+=gap ) { time.setTime( QTime( h, m ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); @@ -1425,7 +1425,7 @@ void DbQuery::getRelationalCountsDay( std::optional& result aux_hour = query.value(0).toInt(); aux_minute = getMinuteGap( query.value(1).toInt(), gap ); if ( aux_hour == hour && aux_minute == minute ) { - count ++; + ++ count; } else { if ( aux_hour == hour ) { // same hour new minute gap, append the last count @@ -1447,13 +1447,13 @@ void DbQuery::getRelationalCountsDay( std::optional& result time.setTime( QTime( hour, m ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } - hour ++; + ++ hour; } else { // prepare to add missing gaps from 00:00 (+gap will be added to the minute) hour = 0; } // append any missing gap in every hour between the current and the next found (aux) - for ( int h{hour}; h& result time.setTime( QTime( hour, m ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } - for ( int h{hour+1}; h<24; h++ ) { + for ( int h{hour+1}; h<24; ++h ) { for ( int m{0}; m<60; m+=gap ) { time.setTime( QTime( h, m ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } } // append the real last fictitious count - day ++; + ++ day; if ( day > getMonthDays( year, month ) ) { day = 1; - month ++; + ++ month; if ( month > 12 ) { month = 1; - year ++; + ++ year; } } time.setDate( QDate( year, month , day ) ); @@ -1647,7 +1647,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res } else if ( ! query.last() ) { // no days found, append missing days with 0 value - for ( int d{from_day}; d<=to_day; d++ ) { + for ( int d{from_day}; d<=to_day; ++d ) { time.setDate( QDate( year, month , d ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } @@ -1663,13 +1663,13 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res while ( query.next() ) { aux_day = query.value(0).toInt(); if ( aux_day == day ) { - count ++; + ++ count; } else { if ( day > 0 ) { // any loop-round except the first time.setDate( QDate( year, month , day ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); - for ( int d{day+1}; d& res m = month, y = year; if ( d < 1 ) { - m --; + -- m; if ( m < 1 ) { m = 12; - y --; + -- y; } d = getMonthDays( y, m ); } - for ( ; d!=aux_day; d++ ) { + for ( ; d!=aux_day; ++d ) { if ( d > getMonthDays( y, m ) ) { d = 1; - m ++; + ++ m; if ( m > 12 ) { m = 1; - y ++; + ++ y; } } time.setDate( QDate( y, m , d ) ); @@ -1708,12 +1708,12 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res time.setDate( QDate( year, month , day ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); // append any missing day from the last found until 1 day before the last one - day++; + ++ day; if ( day > getMonthDays( year, month ) ) { - month ++; + ++ month; if ( month > 12 ) { month = 1; - year ++; + ++ year; } day = getMonthDays( year, month ); } @@ -1723,17 +1723,17 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res y{ year }; if ( m > 12 ) { m = 1; - y ++; + ++ y; } to_day = getMonthDays( y, m ); } - for ( ; day!=to_day; day++ ) { + for ( ; day!=to_day; ++day ) { if ( day > getMonthDays( year, month ) ) { day = 1; - month ++; + ++ month; if ( month > 12 ) { month = 1; - year ++; + ++ year; } } time.setDate( QDate( year, month , day ) ); @@ -1749,7 +1749,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res } else { data.reserve( countDays( from_year, from_month, from_day, to_year, to_month, to_day ) ); - for ( int m{1}; m<=n_months; m++ ) { + for ( int m{1}; m<=n_months; ++m ) { stmt = QString("SELECT \"day\" FROM \"%1\" WHERE \"year\"=%2 AND \"month\"=%3") .arg( web_server ) .arg( year ).arg( month ); @@ -1835,7 +1835,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res // last month, only get the days until the ending day t_d = to_day; } - for ( ; f_d<=t_d; f_d++ ) { + for ( ; f_d<=t_d; ++f_d ) { time.setDate( QDate( year, month , f_d ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } @@ -1848,13 +1848,13 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res while ( query.next() ) { aux_day = query.value(0).toInt(); if ( aux_day == day ) { - count ++; + ++ count; } else { if ( day > 0 ) { // any loop-round except the first time.setDate( QDate( year, month , day ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); - for ( int d{day+1}; d& res } else { // append any missing day until the next found day day = 1; - for ( int d{day}; d& res data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), count ) ); } // append any missing day to the end of the month with a zero value - for ( int d{day+1}; d<=getMonthDays(year,month); d++ ) { + for ( int d{day+1}; d<=getMonthDays(year,month); ++d ) { time.setDate( QDate( year, month , d ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); } } // increase the month - month ++; + ++ month; if ( month > 12 ) { month = 1; - year ++; + ++ year; } } catch (...) { // something failed @@ -1902,7 +1902,7 @@ void DbQuery::getRelationalCountsPeriod( std::optional& res month = to_month +1; if ( month > 12 ) { month = 1; - year ++; + ++ year; } time.setDate( QDate( year, month , day ) ); data.push_back( std::make_tuple( time.toMSecsSinceEpoch(), 0 ) ); @@ -2060,15 +2060,15 @@ bool DbQuery::getGlobalCounts( const QString& web_server, const std::map 0 ) { traf_hour.at( i ) /= n_days; } } // process the day of the week - for ( int i{1}; i<8; i++ ) { + for ( int i{1}; i<8; ++i ) { const int& x{ num_day_count.at( i ) }; if ( x > 0 ) { traf_day.at( i ) /= x; diff --git a/logdoctor/modules/tb.cpp b/logdoctor/modules/tb.cpp index 32187b84..1473268a 100644 --- a/logdoctor/modules/tb.cpp +++ b/logdoctor/modules/tb.cpp @@ -76,7 +76,7 @@ void TextBrowser::makePreview( QString& content ) const /*if ( this->wide_lines ) { content += "
"; }*/ - for ( int i{0}; i<32; i++ ) { + for ( int i{0}; i<32; ++i ) { content += "

"; content += ""; diff --git a/logdoctor/tests/white_box.cpp b/logdoctor/tests/white_box.cpp index 507fdebb..3cded44a 100644 --- a/logdoctor/tests/white_box.cpp +++ b/logdoctor/tests/white_box.cpp @@ -71,7 +71,7 @@ void testUtilities() { const auto every_other_char_but = [](const std::vector& in)->std::vector{ std::vector out( 128-in.size() ); - for (char c{0}; c<127; c++) { + for (char c{0}; c<127; ++c) { if (const auto it = std::find(in.cbegin(),in.cend(),c); it == in.cend()) { out.push_back( c ); } diff --git a/logdoctor/utilities/gzip.cpp b/logdoctor/utilities/gzip.cpp index 9a7e0960..28e8cfe1 100644 --- a/logdoctor/utilities/gzip.cpp +++ b/logdoctor/utilities/gzip.cpp @@ -47,10 +47,7 @@ public: } } - FileHandler(const FileHandler&) = delete; - FileHandler(FileHandler&&) = delete; - FileHandler& operator=(const FileHandler&) = delete; - FileHandler& operator=(FileHandler&&) = delete; + Q_DISABLE_COPY_MOVE(FileHandler) inline operator FILE*() { @@ -144,7 +141,7 @@ void readFile( const std::string& path, std::string& content ) successful = false; break; }*/ - for ( unsigned i{0u}; i& lines, cons srand( (unsigned)time(&nTime) ); size_t index; std::vector picked_indexes; - for( size_t i=0ul; i(rand()) % max; if ( VecOps::contains( picked_indexes, index ) ) { @@ -206,7 +203,7 @@ void randomLines( const std::string& path, std::vector& lines, cons } const std::string& line{ aux_lines.at( index ) }; if ( StringOps::startsWith( line, '#' ) ) { // leave the "#" check for IIS logs - i--; + -- i; continue; } lines.push_back( line ); diff --git a/logdoctor/utilities/printables.cpp b/logdoctor/utilities/printables.cpp index 25c814b1..23cf5185 100644 --- a/logdoctor/utilities/printables.cpp +++ b/logdoctor/utilities/printables.cpp @@ -29,12 +29,12 @@ QString printableSize( const size_t bytes ) } size_t n_decimals{ 3ul }; if ( size >= 100.0 ) { - n_decimals --; + -- n_decimals; if ( size >= 1000.0 ) { - n_decimals --; + -- n_decimals; if ( size >= 10000.0 ) { - n_decimals --; - cut_index --; // no decimals, no "dot" + -- n_decimals; + -- cut_index; // no decimals, no "dot" } } } @@ -69,12 +69,12 @@ QString printableSpeed( const double bytes, const double secs_ ) } size_t n_decimals{ 3ul }; if ( speed >= 100.0 ) { - n_decimals --; + -- n_decimals; if ( speed >= 1000.0 ) { - n_decimals --; + -- n_decimals; if ( speed >= 10000.0 ) { - n_decimals --; - cut_index --; // no decimals, no "dot" + -- n_decimals; + -- cut_index; // no decimals, no "dot" } } } diff --git a/logdoctor/utilities/rtf.cpp b/logdoctor/utilities/rtf.cpp index 1bf6eacc..3c41323b 100644 --- a/logdoctor/utilities/rtf.cpp +++ b/logdoctor/utilities/rtf.cpp @@ -35,7 +35,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co StringOps::splitrip( lines, content ); size_t lines_left{ lines.size() }; for ( const std::string& line : lines ) { - lines_left --; + -- lines_left; // check if the line is commented, usually from IIS logs if ( StringOps::startsWith( line, '#' ) && !StringOps::startsWith( logs_format.initial, '#' ) ) { rich_line = QString("

%1

").arg( QString::fromStdString( line ) ); @@ -74,7 +74,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co } if ( stop == std::string::npos ) { // separator not found, skip to the next one - i++; + ++i; stop = start; continue; } @@ -112,7 +112,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co break; } aux_start = aux_stop + 1; - c++; + ++c; } } @@ -186,7 +186,7 @@ void RichText::enrichLogs( QString& rich_content, const std::string& content, co stop = aux_stop; } else { stop += sep_size; - i++; + ++i; } if ( stop > line_size ) { // this was the final separator diff --git a/logdoctor/utilities/strings.cpp b/logdoctor/utilities/strings.cpp index b5f86758..a9bd101e 100644 --- a/logdoctor/utilities/strings.cpp +++ b/logdoctor/utilities/strings.cpp @@ -10,7 +10,7 @@ size_t count( std::string_view str, std::string_view flag ) { const size_t flg_size{ flag.size() }; size_t count{ 0ul }; - for ( size_t start{0ul}; (start=str.find(flag, start)) != std::string::npos; count++ ) { + for ( size_t start{0ul}; (start=str.find(flag, start)) != std::string::npos; ++count ) { start += flg_size; } return count; @@ -74,7 +74,7 @@ std::string lstripUntil( const std::string& str, const char delim, const bool in { if (size_t start{ str.find( delim ) }; start != std::string::npos ) { if ( inclusive ) { - start ++; + ++ start; if ( consecutives ) { if (str[start] == delim) { start = str.find_first_not_of( delim, start );