Skip to content

Commit

Permalink
Merge pull request #3 from ahans/feature/ahans/pre-commit
Browse files Browse the repository at this point in the history
Feature/ahans/pre commit
  • Loading branch information
ahans authored Mar 24, 2024
2 parents 89b0b56 + 906a08a commit b21f487
Show file tree
Hide file tree
Showing 530 changed files with 4,452 additions and 5,517 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ BasedOnStyle: Google

# Customize with larger indents
IndentWidth: 4
ObjCBlockIndentWidth: 4
ObjCBlockIndentWidth: 4
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@
# Changes to `fetch-configlet` should be made in the `exercism/configlet` repo
bin/fetch-configlet @exercism/maintainers-admin
bin/fetch-configlet.ps1 @exercism/maintainers-admin

1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,3 @@ jobs:
cmake .
cmake --build . -- test_hello-world
cmake --build .
2 changes: 1 addition & 1 deletion .github/workflows/hello-world.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ jobs:
- name: Check Hello World Fails
run: bin/check-hello-world.sh
env:
CXX: ${{ matrix.compiler }}
CXX: ${{ matrix.compiler }}
32 changes: 32 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Pre-commit checks

on:
# Run workflow for PRs.
pull_request:

# Whenever we have a new commit on main, run the workflow for that.
push:
branches: [main]

jobs:
pre-commit:
name: Pre-commit checks
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Run pre-commit checks on PR
if: github.event_name == 'pull_request'
uses: pre-commit/[email protected]
- name: Run pre-commit checks on main
if: github.event_name != 'pull_request'
uses: pre-commit/[email protected]
with:
extra_args: --all
38 changes: 0 additions & 38 deletions .github/workflows/verify-code-formatting.yml

This file was deleted.

15 changes: 15 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
exclude: 'test/(catch.hpp|tests-main.cpp)'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2
hooks:
- id: clang-format
exclude_types: [json]
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@
"cSpell.words": [
"stationprogress"
]
}
}
70 changes: 0 additions & 70 deletions bin/check-formatting.sh

This file was deleted.

2 changes: 1 addition & 1 deletion bin/check-hello-world.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ if cmake --build .; then
exit 1
fi

cd "$repo"
cd "$repo"
2 changes: 1 addition & 1 deletion concepts/auto/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
"url": "https://www.learncpp.com/cpp-tutorial/type-deduction-for-objects-using-the-auto-keyword/",
"description": "Learn C++ overview on the auto keyword and its usage"
}
]
]
6 changes: 3 additions & 3 deletions concepts/basics/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To set off the C++ journey we are starting with variables, function calls, and c

Comments come in two flavors: single- and multi-line.
Everything that comes after `//` on the same line is ignored by the compiler.
Multi-line comments are also known as C-style comments.
Multi-line comments are also known as C-style comments.
They are surrounded by `/*` and `*/`.
Anything that comes between these will be ignored as well.

Expand Down Expand Up @@ -40,7 +40,7 @@ It cannot be stressed enough: avoid undefined behavior at all cost.
## Arithmetic Operations
Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`.
Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`.
## Updating Variables
Expand Down Expand Up @@ -84,7 +84,7 @@ int total_fee(int vips, int adults, int kids) {
*/
int standard_fee{30};
int kids_discount{15};
int kids_total_fee = kids * (standard_fee - kids_discount);
int vips_total_fee = vips * vip_fee(standard_fee);
int adult_total_fee = adults * standard_fee;
Expand Down
6 changes: 3 additions & 3 deletions concepts/basics/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To set off the C++ journey we are starting with variables, function calls, and c

Comments come in two flavors: single- and multi-line.
Everything that comes after `//` on the same line is ignored by the compiler.
Multi-line comments are also known as C-style comments.
Multi-line comments are also known as C-style comments.
They are surrounded by `/*` and `*/`.
Anything that comes between these will be ignored as well.

Expand Down Expand Up @@ -40,7 +40,7 @@ It cannot be stressed enough: avoid undefined behavior at all cost.
## Arithmetic Operations
Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`.
Arithmetic operators like `*`, `+`, or `-` can be part of an expression like `3 * 2` or `tomatoes + potatoes`.
## Updating Variables
Expand Down Expand Up @@ -84,7 +84,7 @@ int total_fee(int vips, int adults, int kids) {
*/
int standard_fee{30};
int kids_discount{15};
int kids_total_fee = kids * (standard_fee - kids_discount);
int vips_total_fee = vips * vip_fee(standard_fee);
int adult_total_fee = adults * standard_fee;
Expand Down
2 changes: 1 addition & 1 deletion concepts/basics/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
"url": "https://isocpp.org/faq",
"description": "C++ Super-FAQ"
}
]
]
2 changes: 1 addition & 1 deletion concepts/booleans/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ If you use a number in a Boolean operation, everything except `0` is treated as
!true && 0.0 // => false
true + true + false // => 2
```
~~~~
~~~~
2 changes: 1 addition & 1 deletion concepts/booleans/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"url": "https://en.cppreference.com/w/cpp/language/operator_logical",
"description": "C++ reference on Logical operators"
}
]
]
2 changes: 1 addition & 1 deletion concepts/classes/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ silverhand.cast_spell();
silverhand.name = "Laeral";
// damage is private:
silverhand.damage = 500;
silverhand.damage = 500;
// => Compilation error
```

Expand Down
4 changes: 2 additions & 2 deletions concepts/classes/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ silverhand.cast_spell();
silverhand.name = "Laeral";
// damage is private:
silverhand.damage = 500;
silverhand.damage = 500;
// => Compilation error
```

Expand Down Expand Up @@ -102,4 +102,4 @@ Conventionally, the `struct` keyword is often used for **data-only structures**.
The `class` keyword is preferred for objects that need to ensure certain properties.
Such an invariant could be that the `damage` of your `Wizzard` `class` cannot turn negative.
The `damage` variable is private and any function that changes the damage would ensure the invariant is preserved.
~~~~
~~~~
2 changes: 1 addition & 1 deletion concepts/classes/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"url": "https://en.cppreference.com/w/cpp/language/classes",
"description": "C++ reference on for classes"
}
]
]
2 changes: 1 addition & 1 deletion concepts/comparisons/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Here are some common examples:
```cpp
bool eq3 = 2 == 3; // false, integer comparison
bool eq4 = 2.1 != 2.2; // true, float comparison
bool eq4 = 2.1 != 2.2; // true, float comparison
bool eq5 = "hello" == "hello"; // true, string comparison
```
Expand Down
2 changes: 1 addition & 1 deletion concepts/comparisons/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Here are some common examples:
```cpp
bool eq3 = 2 == 3; // false, integer comparison
bool eq4 = 2.1 != 2.2; // true, float comparison
bool eq4 = 2.1 != 2.2; // true, float comparison
bool eq5 = "hello" == "hello"; // true, string comparison
```
Expand Down
2 changes: 1 addition & 1 deletion concepts/comparisons/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"url": "https://en.cppreference.com/w/cpp/language/operator_comparison",
"description": "C++ reference on comparison operators"
}
]
]
6 changes: 3 additions & 3 deletions concepts/enums/about.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum class WheelMaterial {
plastic
};
```
Although the wheels and the deck can both be made of _plastic_, the two cannot be confused.
Although the wheels and the deck can both be made of _plastic_, the two cannot be confused.
They are different _types_: `DeckMaterial` plastic and `WheelMaterial` plastic.
Each `enumeration` will have its `enumerators` in its own scope - its own `namespace`.
This is the reason they are called `scoped enumerations`.
Expand All @@ -57,7 +57,7 @@ You might be thinking that with a name like `scoped`, there would also be _`uns
`Unscoped enumerations` are becoming less popular because they all share the same global namespace.
Because of the sharing, you could not have two `unscoped enumerations` with the same `enumerators` like _plastic_ in the example above.
Also, `unscoped enumerations` implicitly convert to integers.
Also, `unscoped enumerations` implicitly convert to integers.
Look at the example below for a surprising result:
```cpp
Expand All @@ -84,4 +84,4 @@ If you want to convert `scoped enumerations` to integers you can use `static_cas
[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming)
[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming)
6 changes: 3 additions & 3 deletions concepts/enums/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ enum class WheelMaterial {
plastic
};
```
Although the wheels and the deck can both be made of _plastic_, the two cannot be confused.
Although the wheels and the deck can both be made of _plastic_, the two cannot be confused.
They are different _types_: `DeckMaterial` plastic and `WheelMaterial` plastic.
Each `enumeration` will have its `enumerators` in its own scope - its own `namespace`.
This is the reason they are called `scoped enumerations`.
Expand All @@ -57,7 +57,7 @@ You might be thinking that with the name `scoped`, there would also be be `unsco
`Unscoped enumerations` are becoming less popular because they all share the same global namespace.
Because of the sharing, you could not have two `unscoped enumerations` with the same `enumerators` like _plastic_ in the example above.
Also, `unscoped enumerations` implicitly convert to integers.
Also, `unscoped enumerations` implicitly convert to integers.
Look at the example below for a surprising result:
```cpp
Expand All @@ -84,4 +84,4 @@ If you want to convert `scoped enumerations` to integers you can use `static_cas
[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming)
[magic numbers]: https://en.wikipedia.org/wiki/Magic_number_(programming)
2 changes: 1 addition & 1 deletion concepts/enums/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
"url": "https://en.cppreference.com/w/cpp/language/enum",
"description": "C++ reference on enumerations"
}
]
]
2 changes: 1 addition & 1 deletion concepts/functions/links.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
"url": "https://en.cppreference.com/w/cpp/language/default_arguments",
"description": "C++ reference on default arguments"
}
]
]
Loading

0 comments on commit b21f487

Please sign in to comment.