Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: adding pre-commit configuration #453

Merged
merged 2 commits into from
Apr 17, 2024
Merged
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
23 changes: 23 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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: 'ad270fb9db427f956ce8eb50c74617ed117b9bfc'
hooks:
- id: clang-format
- repo: https://github.com/pocc/pre-commit-hooks
rev: '336fdd7c3cab698ead0b1c95157b9e74d3906b62'
hooks:
- id: cppcheck
args: [ "--platform=unix64", "-j", "4", "-I include src" ]
- repo: https://github.com/compilerla/conventional-pre-commit
rev: 'v3.2.0'
hooks:
- id: conventional-pre-commit
stages: [ commit-msg ]
args: [ ]
43 changes: 15 additions & 28 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ You will find here a summary of the different things you should do / look up to
## Starting

* First, [fork](https://github.com/ArkScript-lang/Ark/fork) the repository
* Then, clone your fork:
* Then, clone your fork:
* HTTPS: `git clone https://github.com/<username>/Ark.git`
* or SSH: `git clone [email protected]:<username>/Ark.git`
* Install the pre-commit hooks: `pre-commit install` (you may need to [install pre-commit](https://pre-commit.com/#install) first)
* Create a branch for your feature: `git checkout -b feat/my-awesome-idea`
* When you're done, push it to your fork and submit a pull request

Expand All @@ -29,35 +30,21 @@ See the guide [to create a module](https://arkscript-lang.dev/impl/d1/d8c/module

## Submitting a pull request

### Checking the enforcement of the coding style

If it is a C++ project, it is strongly advised to run clang-format on your code *before* submitting a pull request.

You can do as follows if you are a Windows user:
```powershell
Function run-on {
param (
$folder
)
Get-ChildItem -Path $folder -File -Recurse | Foreach {clang-format -style=file -i $_.fullname}
}

run-on .\include\Ark
run-on .\src
```
Code formatting as well as static analysis is handled through `pre-commit` and its hooks. If you don't have it installed, refer back to [Contributing#Starting](#starting).

### Running the test suite

The ArkScript test suite requires the console module for text colors. You can build all the modules by including the `-DARK_BUILD_MODULES` CMake switch when building ArkScript. Once you have the modules built, you can run the ArkScript test suite from the root folder using `./build/arkscript tests/arkscript/unittests.ark --lib ./lib`.

The standard library test suite should be ran from the root folder of the standard library project (the console module will need to be copied to the folder). You can run standard library test suite using `./arkscript tests/all.ark --lib ./`.
Build and run the `arkscript` and `unittests` targets:
- `arkscript tests/arkscript/unittests.ark` (ArkScript unit tests for the VM and builtins)
- `arkscript lib/std/tests/all.ark` (ArkScript unit tests for the standard library)
- `unittests` (various C++ unit tests, testing error messages, AST, parsing...)

## C++ coding guidelines

* Avoid `auto` whenever possible. Using it is tolerated for complex types such as iterators
* Indent with **4 spaces**
* Every brace (`{`, `}`) must be on its own line
* Conditions with a single statement (`if (condition) do_this();`) do not need to be enclosed in braces
* Conditions with a single statement (eg `if (condition) do_this();`) do not need to be enclosed in braces
* Put a space between `for`, `while`, `if` and `(...)`, around each `=` sign (wherever it is, even in for-loops), between `#include` and the file to include
* Prefer `enum class` over `enum`
* Left-const over right-const
Expand Down Expand Up @@ -108,11 +95,11 @@ for (std::size_t i = 0, end = container.size(); i < end; i++)
* @brief Tokenize ArkScript code
* @version 0.1
* @date 2020-10-27
*
*
* @copyright Copyright (c) 2020
*
*
*/

#include <bla>

code...
Expand All @@ -127,9 +114,9 @@ Snippet to recapitulate guidelines for headers:
* @brief Tokenize ArkScript code
* @version 0.1
* @date 2020-10-27
*
*
* @copyright Copyright (c) 2020
*
*
*/

#ifndef HEADER_GUARD
Expand All @@ -149,13 +136,13 @@ namespace Ark
public:
/**
* @brief doxygen documentation here
*
*
*/
Lexer();

/**
* @brief doxygen documentation here
*
*
* @param a_parameter defines the power of the flux capacitor
*/
void aMethod(const std::string& a_parameter);
Expand Down
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ cmake --install build

* First, [fork](https://github.com/ArkScript-lang/Ark/fork) the repository
* Then, clone your fork: `git clone [email protected]:username/Ark.git`
* Install the pre-commit hooks: `pre-commit install` (you may need to [install pre-commit](https://pre-commit.com/#install) first)
* Create a branch for your feature: `git checkout -b feat-my-awesome-idea`
* When you're done, push it to your fork and submit a pull request

Expand Down Expand Up @@ -181,19 +182,19 @@ DESCRIPTION
ArkScript programming language

SYNOPSIS
arkscript -h
arkscript -v
arkscript --dev-info
arkscript -e <expression>
arkscript -c <file> [-d]
arkscript <file> [-d] [-L <lib_dir>]
arkscript -f <file> [--dry-run]
arkscript --ast <file> [-d] [-L <lib_dir>]
arkscript -bcr <file> -on
arkscript -bcr <file> -a [-s <start> <end>]
arkscript -bcr <file> -st [-s <start> <end>]
arkscript -bcr <file> -vt [-s <start> <end>]
arkscript -bcr <file> [-cs] [-p <page>] [-s <start> <end>]
arkscript -h
arkscript -v
arkscript --dev-info
arkscript -e <expression>
arkscript -c <file> [-d]
arkscript <file> [-d] [-L <lib_dir>]
arkscript -f <file> [--dry-run]
arkscript --ast <file> [-d] [-L <lib_dir>]
arkscript -bcr <file> -on
arkscript -bcr <file> -a [-s <start> <end>]
arkscript -bcr <file> -st [-s <start> <end>]
arkscript -bcr <file> -vt [-s <start> <end>]
arkscript -bcr <file> [-cs] [-p <page>] [-s <start> <end>]

OPTIONS
-h, --help Display this message
Expand Down
4 changes: 2 additions & 2 deletions docs/guidelines_coding.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _module_: C++ plugin for the ArkScript virtual machine, allowing use of C++ code

## Precisions

Indentation matters to us, programmers (but not to the compiler): 4 spaces or a single tab, but it should stay consistent accross a project/file.
Indentation matters to us, programmers (but not to the compiler): 4 spaces or a single tab, but it should stay consistent across a project/file.

The general rule of thumb is that a closing parenthesis should never be to the left of its matching opening parenthesis. All new lines should be a couple of spaces to the right of the opening parenthesis of the list they're in.

Expand All @@ -21,7 +21,7 @@ Functions and constants (the ones in the lib and in the builtins) are named foll

* Indent the content of every `begin` block
* When using begin blocks in if (then, else), they should appear clearly as a block, each opening brace on its own line
* When using begin blocks in functions (body), they can appear as an indenpendant block (initial `(begin` or `{` on its own line) or not (initial `(begin` or `{` on the same line as the `fun` keyword)
* When using begin blocks in functions (body), they can appear as an independent block (initial `(begin` or `{` on its own line) or not (initial `(begin` or `{` on the same line as the `fun` keyword)
* closing braces are stacked together, and never preceded by a newline
* if the last instruction wasn't a function call but a variable, a space should be put between those two

Expand Down
Loading