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
6 changes: 4 additions & 2 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
---
BasedOnStyle: Google

AccessModifierOffset: -4

AccessModifierOffset: -2
AlignTrailingComments: true
IndentPPDirectives: AfterHash
IndentWidth: 4
Expand All @@ -15,11 +15,13 @@ BreakBeforeTernaryOperators: true
ColumnLimit: 100
ConstructorInitializerAllOnOneLineOrOnePerLine: true

IncludeBlocks: Regroup
IncludeBlocks: Regroup

SortIncludes: true

SpaceBeforeParens: ControlStatements
AllowShortFunctionsOnASingleLine: InlineOnly
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false

...
Copy link
Collaborator

Choose a reason for hiding this comment

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

добавляй пустые строчки в конце файлов - так должно быть по POSIX, гитхаб будет всегда на это ругаться

31 changes: 31 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Clang Format Check

on:
push:
branches:
- main
pull_request:
branches:
- '**'
Copy link
Collaborator

Choose a reason for hiding this comment

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

лучше делать запуск только при создании PR или push в main, у вас ограниченное число runner-ов на гитхабе. не нужно делать лишние запуски


jobs:
clang-format:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-format

- name: Configure CMake
run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Run Clang Format
run: |
find include source -name '*.cpp' -o -name '*.hpp' | xargs clang-format -i
git diff --exit-code || (echo "Clang format check failed! Run clang-format and commit changes."; exit 1)

49 changes: 49 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Static Analysis Checks

on:
push:
branches:
- main
pull_request:
branches:
- '**'
Copy link
Collaborator

Choose a reason for hiding this comment

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

аналогично про push в main и pr


defaults:
run:
working-directory: .
Copy link
Collaborator

Choose a reason for hiding this comment

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

это не нужно?


jobs:
install-deps:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy

- name: Configure CMake
run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON


clang-tidy:
needs: install-deps
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Restore Cached Build
Copy link
Collaborator

Choose a reason for hiding this comment

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

убрать кеши

uses: actions/cache@v3
with:
path: build
key: ${{ runner.os }}-build-${{ github.sha }}

- name: Run Clang Tidy
run: |
clang-tidy source/*.cpp include/*.hpp



30 changes: 30 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: CppCheck Analysis

on:
push:
branches:
- main
pull_request:
branches:
- '**'
Copy link
Collaborator

Choose a reason for hiding this comment

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

аналогично


jobs:
cppcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y cppcheck

- name: Configure CMake
run: cmake -S . -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON

- name: Run CppCheck
run: |
cppcheck --enable=all --inconclusive --quiet --error-exitcode=1 source/ include/

13 changes: 9 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# IDEs and editors
.idea/
Copy link
Collaborator

Choose a reason for hiding this comment

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

gitignore лучше держать в отсортированном виде.
можно посмотреть на вывод

sort .gitignore

можно оставить комментарии на разделы к чему какие файлы относятся

.vscode/

# Build directories
build/

# Prerequisites
*.d
Copy link
Collaborator

Choose a reason for hiding this comment

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

что это за расширение? оно надо?


# Compiled Object files
*.slo
*.lo
*.o
*.obj
*.slo
*.lo

# Precompiled Headers
*.gch
Expand All @@ -23,10 +28,10 @@ build/
*.smod

# Compiled Static libraries
*.lai
*.la
*.a
*.lib
*.lai
*.la

# Executables
*.exe
Expand Down
33 changes: 12 additions & 21 deletions CMakeLists.txt
Copy link
Collaborator

Choose a reason for hiding this comment

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

давай пока нет исходного кода оставим только нужное, дальше в комментариях

Original file line number Diff line number Diff line change
@@ -1,31 +1,22 @@
cmake_minimum_required(VERSION 3.10)
project(TelegramBot)
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)

Copy link
Collaborator

Choose a reason for hiding this comment

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

добавь комментарии заголовков для разделов CMake

# ---- Project ----

project(MyProject LANGUAGES CXX)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
project(MyProject LANGUAGES CXX)
project(EntryPoint LANGUAGES CXX)


Copy link
Collaborator

Choose a reason for hiding this comment

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

Сделай здесь защиту от дурака, чтобы нельзя было собрать бинарники в директории с сурсами, это есть здесь https://github.com/TheLartians/ModernCppStarter/blob/5115efe66a630f1b25fe51742a7a484e08d0a365/CMakeLists.txt#L14

# ---- Include guards ----

if(PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
  message(
    FATAL_ERROR
      "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there."
  )
endif()

set(CMAKE_CXX_STANDARD 20)
Copy link
Collaborator

Choose a reason for hiding this comment

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

не нужно, ты уже устанвливаешь настройку в 19 строчке для target-а.

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(Boost REQUIRED COMPONENTS system)
find_package(TgBot REQUIRED)
include(cmake/CPM.cmake)

target_include_directories(include)

file(GLOB SOURCES source/*.cpp)
# ---- Add source files ----
# Note: globbing sources is considered bad practice as CMake's generators may not detect new files
# automatically. Keep that in mind when changing files, or explicitly mention them here.
file(GLOB_RECURSE headers CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/include/*.h")
file(GLOB_RECURSE sources CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/source/*.cpp")

add_executable(my_bot ${SOURCES})
add_library(${PROJECT_NAME} ${headers} ${sources})

target_link_libraries(my_bot Boost::system TgBot::TgBot)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20 OUTPUT_NAME "MyApp")
Copy link
Collaborator

Choose a reason for hiding this comment

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

OTPUT_NAME зачем?


target_include_directories(${PROJECT_NAME} PUBLIC include)
Copy link
Collaborator

Choose a reason for hiding this comment

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

target_include_directories(
  ${PROJECT_NAME} PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
                         $<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>
)


if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(my_bot PRIVATE
-g
-fsanitize=address,undefined
-fno-omit-frame-pointer
)
target_link_options(my_bot PRIVATE
-fsanitize=address,undefined
-fno-omit-frame-pointer
)
endif()
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Melnikov Kirill

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ git clone git@github.com:EntryPoint-C-project/EntryPoint.git
cd EntryPoint
# You need to make a telegram-bot token
Copy link
Collaborator

Choose a reason for hiding this comment

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

лучше одной командой. и клонировать репозиторий и перейти в него это spoon-feeding, лучше не надо. Давай так:

Clone repository, go to the directory and run:
...sh
cmake  -S . -B build && cmake --build build
...

mkdir build && cd build
cmake -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. # Enable clang-tidy support
cmake -G Ninja ..
ninja
```
### 🔹 2. Running clang-tidy
```sh
run-clang-tidy -p build/
```
```
24 changes: 24 additions & 0 deletions cmake/CPM.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# SPDX-License-Identifier: MIT
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.40.7)
set(CPM_HASH_SUM "c0fc82149e00c43a21febe7b2ca57b2ffea2b8e88ab867022c21d6b81937eb50")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
elseif(DEFINED ENV{CPM_SOURCE_CACHE})
set(CPM_DOWNLOAD_LOCATION "$ENV{CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
else()
set(CPM_DOWNLOAD_LOCATION "${CMAKE_BINARY_DIR}/cmake/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
endif()

# Expand relative path. This is important if the provided path contains a tilde (~)
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)

file(DOWNLOAD
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
)

include(${CPM_DOWNLOAD_LOCATION})
Copy link
Collaborator

Choose a reason for hiding this comment

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

давай здесь тоже последнюю строчку добавим чтоб гитхаб не ругался

Loading