Skip to content

Commit abe180a

Browse files
authored
Merge pull request rozukke#108 from rozukke/modern-cpp-refactor
Refactor code to be more compliant to modern C++ standards
2 parents d029d7a + 7816a63 commit abe180a

28 files changed

+3067
-2977
lines changed

.clang-format

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
BasedOnStyle: LLVM
2-
IndentWidth: 4
2+
IndentWidth: 2
33
PointerAlignment: Left
4+
ColumnLimit: 100
5+
AccessModifierOffset: -2

.clang-tidy

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright 2019 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
---
16+
# Configure clang-tidy for this project.
17+
18+
# Disabled:
19+
# -google-readability-namespace-comments the *_CLIENT_NS is a macro, and
20+
# clang-tidy fails to match it against the initial value.
21+
Checks: >
22+
-*,
23+
bugprone-*,
24+
google-*,
25+
misc-*,
26+
modernize-*,
27+
performance-*,
28+
portability-*,
29+
readability-*,
30+
-modernize-use-trailing-return-type,
31+
-bugprone-implicit-widening-of-multiplication-result,
32+
-modernize-avoid-c-arrays,
33+
-readability-identifier-length,
34+
-misc-non-private-member-variables-in-classes,
35+
36+
# -google-readability-namespace-comments,
37+
# -google-runtime-int,
38+
# -google-runtime-references,
39+
# -misc-non-private-member-variables-in-classes,
40+
# -readability-named-parameter,
41+
# -readability-braces-around-statements,
42+
# -readability-magic-numbers,
43+
#
44+
# Turn all the warnings from the checks above into errors.
45+
WarningsAsErrors: "*"
46+
47+
CheckOptions:
48+
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
49+
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
50+
- { key: readability-identifier-naming.StructCase, value: CamelCase }
51+
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
52+
- { key: readability-identifier-naming.FunctionCase, value: lower_case }
53+
- { key: readability-identifier-naming.VariableCase, value: lower_case }
54+
- { key: readability-identifier-naming.PrivateMemberPrefix, value: _ }
55+
- { key: readability-identifier-naming.ProtectedMemberPrefix, value: _ }
56+
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
57+
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }
58+
- { key: readability-identifier-naming.EnumConstantPrefix, value: k }
59+
- { key: readability-identifier-naming.ConstexprVariableCase, value: CamelCase }
60+
- { key: readability-identifier-naming.ConstexprVariablePrefix, value: k }
61+
- { key: readability-identifier-naming.GlobalConstantCase, value: UPPER_CASE }
62+
- { key: readability-identifier-naming.MemberConstantCase, value: CamelCase }
63+
- { key: readability-identifier-naming.MemberConstantPrefix, value: k }
64+
- { key: readability-identifier-naming.StaticConstantCase, value: CamelCase }
65+
- { key: readability-identifier-naming.StaticConstantPrefix, value: k }

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ project(mcpp VERSION ${PROJECT_VERSION})
99

1010
set(CMAKE_CXX_STANDARD 17)
1111

12+
# Used for clang-tidy
13+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
14+
1215
if(NOT CMAKE_BUILD_TYPE)
1316
set(CMAKE_BUILD_TYPE Release)
1417
endif()
@@ -72,3 +75,5 @@ target_link_libraries(video_mc ${PROJECT_NAME})
7275
target_link_libraries(obj_mc ${PROJECT_NAME})
7376

7477
add_custom_target(examples DEPENDS hello_minecraft pyramid game_of_life minesweeper video_mc obj_mc)
78+
79+

example/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Checks: "-*"

0 commit comments

Comments
 (0)