Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions sandbox/template/src/foo.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#pragma once

void Bar() {}
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: function 'Bar' defined in a header file; function definitions in header files can lead to ODR violations [misc-definitions-in-headers]

void Bar() {}
     ^
Additional context

sandbox/template/src/foo.hpp:2: make as 'inline'

void Bar() {}
     ^

25 changes: 24 additions & 1 deletion sandbox/template/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
#include <bits/atomic_wait.h>
#include <iostream>
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: included header atomic_wait.h is not used directly [misc-include-cleaner]

Suggested change
#include <iostream>
#include <iostream>


int main() { return 0; }
#include "utils.hpp"

int main() {
utils::IntArray a(10);

for (int i = 0; i < a.GetSize(); ++i) {
a[i] = i;
}

int sum = 0;
for (int i = 0; i < a.GetSize(); ++i) {
sum += a[i];
}

std::cout << sum << '\n';

utils::IntArray adda;
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: call to deleted constructor of 'utils::IntArray' [clang-diagnostic-error]

  utils::IntArray adda;
                  ^
Additional context

sandbox/template/src/utils.hpp:16: 'IntArray' has been explicitly marked deleted here

  IntArray() = delete;
  ^

utils::IntArray b(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 'b' of type 'utils::IntArray' can be declared 'const' [misc-const-correctness]

Suggested change
utils::IntArray b(1, 1);
utils::IntArray const b(1, 1);


{ utils::IntArray a; }
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: call to deleted constructor of 'utils::IntArray' [clang-diagnostic-error]

  { utils::IntArray a; }
                    ^
Additional context

sandbox/template/src/utils.hpp:16: 'IntArray' has been explicitly marked deleted here

  IntArray() = delete;
  ^


return 0;
}
51 changes: 51 additions & 0 deletions sandbox/template/src/utils.cpp
Original file line number Diff line number Diff line change
@@ -1 +1,52 @@
#include "utils.hpp"
#include <climits>
#include <cstddef>
#include <iostream>
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: included header cstddef is not used directly [misc-include-cleaner]

Suggested change
#include <iostream>
#include <iostream>

#include <stdexcept>

namespace utils {

// IntArray::IntArray() : data_(nullptr), size_(0), bar("Bar"), foo() {
// std::cout << "IntArray::IntArray()\n";
// }

IntArray::IntArray(int size) : foo(size), bar("Bar") {
std::cout << "IntArray::IntArray(int size = " << size << ")\n ";
data_ = new int[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: 'data_' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

sandbox/template/src/utils.cpp:12:

- IntArray::IntArray(int size) : foo(size), bar("Bar") {
+ IntArray::IntArray(int size) : foo(size), bar("Bar"), data_(new int[size]) {
Suggested change
data_ = new int[size];

size_ = 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: 'size_' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

sandbox/template/src/utils.cpp:12:

- IntArray::IntArray(int size) : foo(size), bar("Bar") {
+ IntArray::IntArray(int size) : foo(size), bar("Bar"), size_(size) {
Suggested change
size_ = size;

}

IntArray::IntArray(int num, int size) {
std::cout << "IntArray::IntArray(int num = " << num << "int size " << size
<< ")\n";
data_ = new int[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: 'data_' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

sandbox/template/src/utils.cpp:18:

- IntArray::IntArray(int num, int size) {
+ IntArray::IntArray(int num, int size) : data_(new int[size]) {
Suggested change
data_ = new int[size];

size_ = 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: 'size_' should be initialized in a member initializer of the constructor [cppcoreguidelines-prefer-member-initializer]

sandbox/template/src/utils.cpp:18:

- IntArray::IntArray(int num, int size) {
+ IntArray::IntArray(int num, int size), size_(size) {
Suggested change
size_ = size;

for (int i = 0; i < size; ++i) {
data_[i] = num;
}
}

IntArray::~IntArray() {
Clear();
std::cout << "IntArray::~IntArray()\n";
}

int IntArray::GetSize() const { return size_; }

bool IntArray::IsEmpty() const { return !size_; }

int &IntArray::operator[](int index) {
if (index < 0)
throw std::out_of_range("index is negative");
if (index >= size_)
throw std::out_of_range("index is too big");
return data_[index];
}

void IntArray::Clear() {
delete[] data_;
data_ = nullptr;
size_ = 0;
}

} // namespace utils
38 changes: 38 additions & 0 deletions sandbox/template/src/utils.hpp
Original file line number Diff line number Diff line change
@@ -1 +1,39 @@
#pragma once

#include <iostream>

namespace utils {

class Foo {
public:
Foo() { std::cout << "Foo()\n"; }
Foo(int) { std::cout << "Foo(int)\n"; }
Foo(const std::string &s) { std::cout << s << "(string)\n"; }
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: no header providing "std::string" is directly included [misc-include-cleaner]

sandbox/template/src/utils.hpp:3:

+ #include <string>

~Foo() { std::cout << "~Foo()\n"; }
};

class IntArray {
public:
IntArray() = delete;
IntArray(int size);
IntArray(int num, int size);
~IntArray();

int GetSize() const;

bool IsEmpty() const;

void Resize(int size);

int &operator[](int index);

void Clear();

private:
Foo foo;
Foo bar;
int *data_;
int size_;
};

} // namespace utils
6 changes: 5 additions & 1 deletion task_01/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#include <iostream>

int main() { return 0; }
int main() {
std::cout << "Hello, world!\n";

return 0;
}
3 changes: 3 additions & 0 deletions task_01/src/sum.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "sum.hpp"

int Sum(int first_number, int second_number, int third_number) { return 6; }
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 'first_number' is unused [misc-unused-parameters]

Suggested change
int Sum(int first_number, int second_number, int third_number) { return 6; }
int Sum(int /*first_number*/, int second_number, int third_number) { return 6; }

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 'second_number' is unused [misc-unused-parameters]

Suggested change
int Sum(int first_number, int second_number, int third_number) { return 6; }
int Sum(int first_number, int /*second_number*/, int third_number) { return 6; }

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 'third_number' is unused [misc-unused-parameters]

Suggested change
int Sum(int first_number, int second_number, int third_number) { return 6; }
int Sum(int first_number, int second_number, int /*third_number*/) { return 6; }

2 changes: 1 addition & 1 deletion task_01/src/sum.hpp
Original file line number Diff line number Diff line change
@@ -1 +1 @@
int Sum(int first_number, int second_number, int third_number) { return 6; }
int Sum(int first_number, int second_number, int third_number);
39 changes: 39 additions & 0 deletions task_05/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
cmake_minimum_required(VERSION 3.10)

get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
string(REPLACE " " "_" PROJECT_NAME ${PROJECT_NAME})
project(${PROJECT_NAME} C CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

file(GLOB_RECURSE source_list "src/*.cpp" "src/*.hpp")
file(GLOB_RECURSE lib_source_list "../lib/src/*.cpp" "../lib/src/*.hpp")
file(GLOB_RECURSE main_source_list "src/main.cpp")
file(GLOB_RECURSE test_source_list "src/*.cpp")
file(GLOB_RECURSE test_list "src/*test.cpp")

list(REMOVE_ITEM test_source_list ${main_source_list})
list(REMOVE_ITEM source_list ${test_list})

include_directories(${PROJECT_NAME} PUBLIC src)
include_directories(${PROJECT_NAME} PUBLIC ../lib/src)

add_executable(${PROJECT_NAME} ${source_list})
target_link_libraries(${PROJECT_NAME} PUBLIC Utils)

# Locate GTest
enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

# Link runTests with what we want to test and the GTest and pthread library
add_executable(${PROJECT_NAME}_tests ${test_source_list})
target_link_libraries(
${PROJECT_NAME}_tests
GTest::gtest_main
Utils
)

include(GoogleTest)
gtest_discover_tests(${PROJECT_NAME}_tests)
3 changes: 3 additions & 0 deletions task_05/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Сдвиг элементов

Создайте функцию, которая принимает указатель на массив целых чисел, его размер, и целое число N. Функция должна сдвинуть все элементы массива на N позиций вправо, чтобы первые элементы стали последними. Элементы, которые "выталкиваются" из массива, должны появиться с левой стороны.
3 changes: 3 additions & 0 deletions task_05/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include <iostream>

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: included header iostream is not used directly [misc-include-cleaner]

Suggested change

int main() { return 0; }
6 changes: 6 additions & 0 deletions task_05/src/test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

#include <gtest/gtest.h>

TEST(TopologySort, Simple) {
ASSERT_EQ(1, 1); // Stack []
}
Loading