Skip to content

Readme & tasks 1,2, 4, 5 - #6

Open
AldMatvey wants to merge 10 commits into
DafeMipt213:mainfrom
AldMatvey:main
Open

Readme & tasks 1,2, 4, 5#6
AldMatvey wants to merge 10 commits into
DafeMipt213:mainfrom
AldMatvey:main

Conversation

@AldMatvey

Copy link
Copy Markdown
Contributor

No description provided.

@LostPointer

Copy link
Copy Markdown
Contributor

Доки по программе в отдельным ПРом нужно делать

@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 98. Check the log or trigger a new build to see more.


TEST(Template, Simple) { ASSERT_EQ(true, true); }
TEST(Template, Easy) {
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11};

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 'vec' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11};
std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11};

ASSERT_EQ(rmq.findMin(1, 7), 1);
}
TEST(Template, Medium) {
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11};

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 'vec' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11};
std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11};

ASSERT_EQ(rmq.findMin(6, 7), 1);
}
TEST(Template, Hard) {
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11};

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 'vec' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11};
std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11};

ASSERT_EQ(rmq.findMin(3, 4), 3);
}
TEST(Template, Harder) {
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12};

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 'vec' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12};
std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11, 12};

ASSERT_EQ(rmq.findMin(7, 8), 11);
}
TEST(Template, Comlicated) {
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12, 1, 1, 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 'vec' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<int> vec{1, 10, 7, 6, 3, 2, 1, 11, 12, 1, 1, 1};
std::vector<int> vec = 0{1, 10, 7, 6, 3, 2, 1, 11, 12, 1, 1, 1};

Comment thread task_01/src/test.cpp
ASSERT_EQ(graph.topologySort(0), res);
}
TEST(TopologySort, Comlex) {
std::vector<std::vector<int>> input = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}};

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 'input' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<std::vector<int>> input = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}};
std::vector<std::vector<int>> input = 0 = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}};

Comment thread task_01/src/test.cpp
TEST(TopologySort, Comlex) {
std::vector<std::vector<int>> input = {{1, 2}, {3}, {3, 4}, {1, 4}, {0}, {}, {7, 8}, {10}, {9, 10}, {6, 11}, {7}, {}, {9, 10, 11}};
Graph graph(input);
std::vector<int> res = {5, 12, 9, 11, 6, 8, 7, 10, 0, 2, 1, 3, 4};

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 'res' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<int> res = {5, 12, 9, 11, 6, 8, 7, 10, 0, 2, 1, 3, 4};
std::vector<int> res = 0 = {5, 12, 9, 11, 6, 8, 7, 10, 0, 2, 1, 3, 4};

Comment thread task_01/src/test.cpp
}

TEST(TopologySort, Empty) {
std::vector<std::vector<int>> input = {{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 'input' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<std::vector<int>> input = {{0}};
std::vector<std::vector<int>> input = 0 = {{0}};

Comment thread task_01/src/test.cpp
TEST(TopologySort, Empty) {
std::vector<std::vector<int>> input = {{0}};
Graph graph(input);
std::vector<int> res = {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 'res' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<int> res = {0};
std::vector<int> res = 0 = {0};

Comment thread task_01/src/test.cpp
}

TEST(TopologySort, FullGraphLoops) {
std::vector<std::vector<int>> input = {{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}};

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 'input' is not initialized [cppcoreguidelines-init-variables]

Suggested change
std::vector<std::vector<int>> input = {{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}};
std::vector<std::vector<int>> input = 0 = {{0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}, {0, 1, 2, 3, 4}};

@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

{
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;
                          ^


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;


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

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;

}

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
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
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
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
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>
         ^

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