Skip to content

Commit

Permalink
Merge pull request #2 from YACLib/kononovk-setup
Browse files Browse the repository at this point in the history
Setup repo
  • Loading branch information
MBkkt authored May 18, 2023
2 parents 7d600aa + 8263150 commit 8a92d55
Show file tree
Hide file tree
Showing 51 changed files with 6,820 additions and 1 deletion.
38 changes: 38 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
BasedOnStyle: Google
Language: Cpp
Standard: c++17
UseTab: Never
DerivePointerAlignment: false
PointerAlignment: Left
ColumnLimit: 120

AllowShortLambdasOnASingleLine: None
AllowShortFunctionsOnASingleLine: None
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortEnumsOnASingleLine: true # if false then enums would be formatted as Allman braces style
AllowShortIfStatementsOnASingleLine: Never
AllowShortLoopsOnASingleLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowAllArgumentsOnNextLine: false
LambdaBodyIndentation: Signature
BraceWrapping:
BeforeLambdaBody: true
AlignEscapedNewlines: Right
ContinuationIndentWidth: 2
ConstructorInitializerIndentWidth: 2
AlignAfterOpenBracket: Align

IncludeCategories:
- Regex: '^".*"$' # relative includes
Priority: 10
- Regex: '^<ione\/.*>$' # our library public includes
Priority: 30
- Regex: '^<[[:alpha:]_\/]+>$' # STL
Priority: 40
- Regex: '^<.*\.hpp>$' # our library private includes
Priority: 20
- Regex: '.*' # other libraries (system headers in our case)
Priority: 50
IncludeBlocks: Regroup
IndentPPDirectives: AfterHash
73 changes: 73 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
Checks: '*,
-abseil-*,
-altera-*,
-android-*,
-boost-*,
-google-objc-*,
-linuxkernel-*,
-llvmlibc-*,
-mpi-*,
-objc-*,
-openmp-*,
-cert-err58-cpp,
-cppcoreguidelines-pro-type-static-cast-downcast,
-fuchsia-default-arguments-*,
-google-build-using-namespace,
-modernize-use-trailing-return-type,
-readability-identifier-length,
-fuchsia-overloaded-operator,
-cppcoreguidelines-pro-type-union-access,
-hicpp-named-parameter,
-modernize-use-default-member-init,
-readability-named-parameter,
-google-explicit-constructor,
-hicpp-explicit-conversions,
-llvm-header-guard,
-cppcoreguidelines-owning-memory'

WarningsAsErrors: '*'

HeaderFilterRegex: '^<.*\.hpp>$'

CheckOptions:
- key: readability-identifier-naming.NamespaceCase
value: lower_case
- key: readability-identifier-naming.ClassCase
value: CamelCase
- key: readability-identifier-naming.StructCase
value: CamelCase
- key: readability-identifier-naming.TypedefCase
value: CamelCase
- key: readability-identifier-naming.TypeAliasCase
value: CamelCase
- key: readability-identifier-naming.FunctionCase
value: CamelCase
- key: readability-identifier-naming.ParameterCase
value: lower_case
- key: readability-identifier-naming.VariableCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberCase
value: lower_case
- key: readability-identifier-naming.PrivateMemberPrefix
value: _
- key: readability-identifier-naming.GlobalConstantCase
value: CamelCase
- key: readability-identifier-naming.GlobalConstantPrefix
value: k
- key: readability-identifier-naming.StaticConstantCase
value: CamelCase
- key: readability-identifier-naming.StaticConstantPrefix
value: k
- key: readability-identifier-naming.ConstexprVariableCase
value: CamelCase
- key: readability-identifier-naming.ConstexprVariablePrefix
value: k
- key: readability-identifier-naming.TypeTemplateParameterCase
value: CamelCase
- key: readability-simplify-boolean-expr.ChainedConditionalReturn
value: 1
- key: readability-simplify-boolean-expr.ChainedConditionalAssignment
value: 1
- key: misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic
value: 1
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
15 changes: 15 additions & 0 deletions .githooks/how_to_use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# How to use git hooks for this repository:

* Set `.githooks` directory as root directory for git hooks:

```bash
git config --local core.hooksPath ./.githooks
```

or

* Copy `pre-commit` file to `.git/hooks`:

```bash
cp ./.githooks/pre-commit ./.git/hooks/
```
58 changes: 58 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env python

import subprocess


def last_line_valid(path):
"""
Check last file line have linebreak
:param path: path to file
:return: have or haven't
"""
with open(path, 'r') as f:
text = f.readlines()
try:
last_char = text[-1][-1]
return last_char == '\n'
except IndexError:
return False


def fix_last_line(path):
"""
Add a linebreak to the end of file if it doesn't have one
"""
if last_line_valid(path):
return
with open(path, 'a') as f:
print(f'Add linebreak to the file: {path}')
f.write('\n')


def fix_clang_format(path):
"""
Fix clang-format
"""
if path.endswith('.cpp') or path.endswith('.hpp'):
print(f'clang-format fix: {path}')
subprocess.Popen(['clang-format', path, '-i'], stdout=subprocess.DEVNULL).communicate()


def fix_format():
git_diff = subprocess.Popen('git diff-index --name-status --cached HEAD'.split(), stdout=subprocess.PIPE)
remove_deleted = subprocess.Popen('grep -v ^D'.split(), stdin=git_diff.stdout, stdout=subprocess.PIPE)
get_second_column = subprocess.Popen(['awk', '{ print $2 }'], stdin=remove_deleted.stdout, stdout=subprocess.PIPE)
git_diff.stdout.close()
remove_deleted.stdout.close()
output = get_second_column.communicate()[0].decode('utf-8').strip()
if not output:
return
for file in output.split('\n'):
path = f'./{file}'
fix_last_line(path)
fix_clang_format(path)
subprocess.Popen(['git', 'add'] + output.split('\n')).communicate()


if __name__ == '__main__':
fix_format()
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @MBkkt @kononovk
38 changes: 38 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
17 changes: 17 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
### Purpose

~~Please use labels for this PR~~

~~Please describe the changes in this PR for reviewers~~

### Related Information

- [ ] Design document: ...
- [ ] Bench PR: ...

### Testing

- [ ] This change is a trivial rework or code cleanup without any test coverage.
- [ ] This change is already covered by existing tests.
- [ ] This PR adds tests that were used to verify all changes.
- [ ] There are tests in an external testing repository: ...
Loading

0 comments on commit 8a92d55

Please sign in to comment.