Skip to content

Tasks - #8

Open
AldMatvey wants to merge 17 commits into
DafeMipt213:mainfrom
AldMatvey:Tasks
Open

Tasks#8
AldMatvey wants to merge 17 commits into
DafeMipt213:mainfrom
AldMatvey:Tasks

Conversation

@AldMatvey

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

There were too many comments to post at once. Showing the first 25 out of 128. Check the log or trigger a new build to see more.

Comment thread sandbox/template/src/test.cpp Outdated
Comment thread sandbox/template/src/test.cpp Outdated
Comment thread sandbox/template/src/test.cpp Outdated
Comment thread sandbox/template/src/test.cpp Outdated
Comment thread sandbox/template/src/test.cpp Outdated
Comment thread task_01/src/test.cpp Outdated
Comment thread task_01/src/test.cpp
Comment thread task_01/src/test.cpp
Comment thread task_01/src/test.cpp
Comment thread task_01/src/test.cpp Outdated

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_01/src/topology_sort.cpp Outdated
{
if(colors[i] == 0)
{
still_white = i;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

            still_white = i;
                          ^

Comment thread task_01/src/topology_sort.cpp Outdated

Graph::Graph(std::vector<std::vector<int>> new_graph)
{
graph_list = new_graph;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'graph_list' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

task_01/src/topology_sort.cpp:63:

- Graph::Graph(std::vector<std::vector<int>> new_graph)
+ Graph::Graph(std::vector<std::vector<int>> new_graph) : graph_list(new_graph)
Suggested change
graph_list = new_graph;

Comment thread task_01/src/topology_sort.cpp Outdated

Graph::Graph(std::vector<std::vector<int>> new_graph)
{
graph_list = new_graph;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'new_graph' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]

    graph_list = new_graph;
                 ^

this fix will not be applied because it overlaps with another fix

Comment thread task_01/src/topology_sort.cpp Outdated
Graph::Graph(std::vector<std::vector<int>> new_graph)
{
graph_list = new_graph;
timer = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'timer' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

task_01/src/topology_sort.cpp:63:

- Graph::Graph(std::vector<std::vector<int>> new_graph)
+ Graph::Graph(std::vector<std::vector<int>> new_graph), timer(0)
Suggested change
timer = 0;

Comment thread task_02/src/bridges_and_cutpoints.cpp Outdated
}

std::set<std::pair<int, int>> findBridges (const std::vector<std::vector<int>>& graph){
int time = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'time' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int time = 0;
int const time = 0;

Comment thread task_05/src/RMQ.cpp Outdated
size_t pow_len = std::pow(2, pow);
minimum_table.push_back(input_vector);
minimum_table[0].resize(pow_len, __INT_MAX__);
int current_pow = pow - 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: Value stored to 'current_pow' during its initialization is never read [clang-analyzer-deadcode.DeadStores]

    int current_pow = pow - 1;
        ^
Additional context

task_05/src/RMQ.cpp:9: Value stored to 'current_pow' during its initialization is never read

    int current_pow = pow - 1;
        ^

Comment thread task_05/src/RMQ.cpp Outdated
size_t pow_len = std::pow(2, pow);
minimum_table.push_back(input_vector);
minimum_table[0].resize(pow_len, __INT_MAX__);
int current_pow = pow - 1;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

    int current_pow = pow - 1;
                      ^

Comment thread task_05/src/RMQ.cpp Outdated
int RMQ::findMin(const unsigned int left, const unsigned int right){
if(left > right || left < 0 || right > minimum_table[0].size())
throw std::out_of_range ("wrong border arguments");
size_t row = std::floor(std::log2(right - left + 1));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'row' of type 'size_t' (aka 'unsigned long') can be declared 'const' [misc-const-correctness]

Suggested change
size_t row = std::floor(std::log2(right - left + 1));
size_t const row = std::floor(std::log2(right - left + 1));

Comment thread task_05/src/RMQ.cpp Outdated
if(left > right || left < 0 || right > minimum_table[0].size())
throw std::out_of_range ("wrong border arguments");
size_t row = std::floor(std::log2(right - left + 1));
return std::min(minimum_table[row][left], minimum_table[row][right - std::pow(2, row) + 1]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'typename __gnu_cxx::__promote_2<int, unsigned long>::__type' (aka 'double') to 'size_type' (aka 'unsigned long') [cppcoreguidelines-narrowing-conversions]

    return std::min(minimum_table[row][left], minimum_table[row][right - std::pow(2, row) + 1]);
                                                                 ^

Comment thread task_05/src/test.cpp
@@ -1,6 +1,72 @@

#include <gtest/gtest.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]

#include <gtest/gtest.h>
         ^

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_03/src/Jonson.cpp Outdated
std::vector<int> d(static_cast<size_t> (graph.size()));

if(fordBellman(graph.size(), graph, d) == 0){
throw std::runtime_error("negative cycle");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

st<size_t> (graph.size()));
                                                ^

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_01/src/topology_sort.cpp Outdated
}

Graph::Graph(std::vector<std::vector<int>> new_graph)
: graph_list(new_graph), timer(0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'new_graph' is passed by value and only copied once; consider moving it to avoid unnecessary copies [performance-unnecessary-value-param]

task_01/src/topology_sort.cpp:1:

+ 
+ #include <utility>
Suggested change
: graph_list(new_graph), timer(0) {
: graph_list(std::move(new_graph)), timer(0) {

Comment thread task_03/src/Jonson.cpp
std::vector<int> d(static_cast<size_t>(graph.size()));

if (fordBellman(graph.size(), graph, d) == 0) {
throw std::runtime_error("negative cycle");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

ast<size_t>(graph.size()));
                                               ^

Comment thread task_04/src/main.cpp
#include "Dijkstra.hpp"

int main() {
std::vector<std::vector<Vertex>> graph = {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'graph' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]

Suggested change
std::vector<std::vector<Vertex>> graph = {
std::vector<std::vector<Vertex>> const graph = {

Comment thread task_06/src/LCA.cpp Outdated
#include "LCA.hpp"


Node::Node(int val) : value(val), height(0), used(false) {}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: constructor does not initialize these fields: left_child, right_child [cppcoreguidelines-pro-type-member-init]

task_06/src/LCA.hpp:9:

-   Node *left_child;
-   Node *right_child;
+   Node *left_child{};
+   Node *right_child{};

Comment thread task_06/src/LCA.cpp Outdated
values.push_back(current_vertex->value);
current_vertex->height = current_height;
current_vertex->used = true;
indexes[current_vertex->value] = values.size();

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'mapped_type' (aka 'int') is implementation-defined [cppcoreguidelines-narrowing-conversions]

  indexes[current_vertex->value] = values.size();
                                   ^

Comment thread task_06/src/LCA.cpp Outdated
}

int BinaryTree::findMin(int value1, int value2) {
int left = std::min(indexes[value1], indexes[value2]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'left' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int left = std::min(indexes[value1], indexes[value2]);
int const left = std::min(indexes[value1], indexes[value2]);

Comment thread task_06/src/LCA.cpp Outdated

int BinaryTree::findMin(int value1, int value2) {
int left = std::min(indexes[value1], indexes[value2]);
int right = std::max(indexes[value1], indexes[value2]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'right' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int right = std::max(indexes[value1], indexes[value2]);
int const right = std::max(indexes[value1], indexes[value2]);

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_05/src/RMQ.cpp Outdated
const size_t pow_len = static_cast<size_t>(std::pow(2, pow));
std::vector<TableElement> first_row;
for (size_t i = 0; i < input_vector.size(); ++i) {
first_row.push_back(TableElement(input_vector[i], i));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

    first_row.push_back(TableElement(input_vector[i], i));
                                                      ^

Comment thread task_05/src/RMQ.cpp Outdated
first_row.push_back(TableElement(input_vector[i], i));
}
for (size_t i = input_vector.size(); i < pow_len; ++i) {
first_row.push_back(TableElement(__INT_MAX__, i));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

    first_row.push_back(TableElement(__INT_MAX__, i));
                                                  ^

Comment thread task_06/src/LCA.cpp
@@ -0,0 +1,62 @@
#include "LCA.hpp"

#include "../../task_05/src/RMQ.cpp"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: suspicious #include of file with '.cpp' extension [bugprone-suspicious-include]

#include "../../task_05/src/RMQ.cpp"
          ^
Additional context

task_06/src/LCA.cpp:2: did you mean to include '../../task_05/src/RMQ.hpp'?

#include "../../task_05/src/RMQ.cpp"
          ^

Comment thread task_06/src/test.cpp
@@ -1,6 +1,146 @@

#include <gtest/gtest.h>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: 'gtest/gtest.h' file not found [clang-diagnostic-error]

#include <gtest/gtest.h>
         ^

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread task_03/src/Jonson.cpp
std::vector<int> d(static_cast<int>(graph.size()));

if (fordBellman(graph.size(), graph, d) == 0) {
throw std::runtime_error("negative cycle");

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_type' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

c_cast<int>(graph.size()));
                                               ^

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

#include "prim.hpp"

int main() {
std::vector<std::vector<Vertex>> graph{

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'graph' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]

Suggested change
std::vector<std::vector<Vertex>> graph{
std::vector<std::vector<Vertex>> const graph{

{{3, 2}, {0, 7}, {5, 3}},
{{4, 3}, {0, 10}, {6, 4}},
{{0, 1}, {5, 4}}};
std::vector<std::vector<Vertex>> tree = prim(graph);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'tree' of type 'std::vector<std::vector>' can be declared 'const' [misc-const-correctness]

Suggested change
std::vector<std::vector<Vertex>> tree = prim(graph);
std::vector<std::vector<Vertex>> const tree = prim(graph);

if (!colors[graph[i][j].destination]) {
if (min > graph[i][j].weight) {
min = graph[i][j].weight;
x = i;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

              x = i;
                  ^

if (min > graph[i][j].weight) {
min = graph[i][j].weight;
x = i;
y = j;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: narrowing conversion from 'size_t' (aka 'unsigned long') to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]

              y = j;
                  ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants