From 19d0ea803df756164c91ac142949d9e74c60b4e8 Mon Sep 17 00:00:00 2001 From: John Bampton Date: Sun, 31 Dec 2023 21:57:58 +1000 Subject: [PATCH] Fix `pre-commit` failure from `prettier` --- .github/linters/.yaml-lint.yml | 2 ++ .github/workflows/oss-fuzz.yml | 4 ++-- .github/workflows/super-linter.yml | 4 ++-- .gitignore | 1 + .pre-commit-config.yaml | 1 + .prettierrc | 3 +++ SECURITY.md | 2 +- build_config/dreamcast_shelf.rb | 2 +- doc/guides/compile.md | 4 ++-- doc/guides/debugger.md | 4 ++-- doc/guides/gc-arena-howto.md | 2 +- doc/guides/link.md | 12 ++++++------ doc/guides/mrbconf.md | 8 ++++---- doc/guides/mrbgems.md | 6 +++--- doc/guides/symbol.md | 14 +++++++------- doc/internal/boxing.md | 4 ++-- doc/mruby3.0.md | 9 +++++---- docker-compose.yml | 2 +- mrbgems/mruby-bigint/README-fgmp.md | 16 ++++++++-------- mrbgems/mruby-io/README.md | 4 ++-- mrbgems/mruby-pack/README.md | 2 +- 21 files changed, 57 insertions(+), 49 deletions(-) create mode 100644 .prettierrc diff --git a/.github/linters/.yaml-lint.yml b/.github/linters/.yaml-lint.yml index be4c88798..f5e0ee462 100644 --- a/.github/linters/.yaml-lint.yml +++ b/.github/linters/.yaml-lint.yml @@ -4,6 +4,8 @@ extends: default rules: + comments: + min-spaces-from-content: 1 document-start: disable line-length: disable truthy: false diff --git a/.github/workflows/oss-fuzz.yml b/.github/workflows/oss-fuzz.yml index ce5023a67..c4e0b3d10 100644 --- a/.github/workflows/oss-fuzz.yml +++ b/.github/workflows/oss-fuzz.yml @@ -11,12 +11,12 @@ jobs: - name: Build Fuzzers uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master with: - oss-fuzz-project-name: 'mruby' + oss-fuzz-project-name: "mruby" dry-run: false - name: Run Fuzzers uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master with: - oss-fuzz-project-name: 'mruby' + oss-fuzz-project-name: "mruby" fuzz-seconds: 600 dry-run: false - name: Upload Crash diff --git a/.github/workflows/super-linter.yml b/.github/workflows/super-linter.yml index 8d817ef4d..d250a7f98 100644 --- a/.github/workflows/super-linter.yml +++ b/.github/workflows/super-linter.yml @@ -9,8 +9,8 @@ permissions: jobs: build: permissions: - contents: read # for actions/checkout to fetch code - statuses: write # for github/super-linter/slim to mark status of each linter run + contents: read # for actions/checkout to fetch code + statuses: write # for github/super-linter/slim to mark status of each linter run name: Lint Code Base runs-on: ubuntu-latest steps: diff --git a/.gitignore b/.gitignore index eb5b5ddfa..e604347b9 100644 --- a/.gitignore +++ b/.gitignore @@ -31,5 +31,6 @@ compile_commands.json compile_flags.txt cscope.files cscope.out +node_modules tags !Gemfile.lock diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e66cc3b3d..d344920fd 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,6 +54,7 @@ repos: rev: v4.0.0-alpha.8 hooks: - id: prettier + exclude: ^doc/internal/opcode\.md$ - repo: https://github.com/igorshubovych/markdownlint-cli rev: v0.38.0 hooks: diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..81b81d20d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "bracketSpacing": false +} diff --git a/SECURITY.md b/SECURITY.md index 779b06c32..bd80d2dd9 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -11,7 +11,7 @@ We consider the following issues as vulnerabilities: - Remote code execution - Crash caused by a valid Ruby script -We *don't* consider the following issues as vulnerabilities: +We _don't_ consider the following issues as vulnerabilities: - Runtime C undefined behavior (including integer overflow) - Crash caused by misused API diff --git a/build_config/dreamcast_shelf.rb b/build_config/dreamcast_shelf.rb index 7a4cc1afc..0edd9470c 100644 --- a/build_config/dreamcast_shelf.rb +++ b/build_config/dreamcast_shelf.rb @@ -34,7 +34,7 @@ MRuby::CrossBuild.new("dreamcast") do |conf| cc.defines << %w(_arch_sub_pristine) end - # C++ compiler + # C++ compiler conf.cxx do |cxx| cxx.command = conf.cc.command.dup cxx.include_paths = conf.cc.include_paths.dup diff --git a/doc/guides/compile.md b/doc/guides/compile.md index 579a49d7a..dab175613 100644 --- a/doc/guides/compile.md +++ b/doc/guides/compile.md @@ -80,7 +80,7 @@ conf.toolchain :clang #### Visual Studio 2010, 2012 and 2013 Toolchain configuration for Visual Studio on Windows. If you use the -[Visual Studio Command Prompt](https://msdn.microsoft.com/en-us/library/ms229859\(v=vs.110\).aspx), +[Visual Studio Command Prompt](), you normally do not have to specify this manually, since it gets automatically detected by our build process. ```ruby @@ -460,7 +460,7 @@ compile for `i386` a directory called `i386` is created under the build directory. The cross compilation workflow starts in the same way as the normal -compilation by compiling all *native* libraries and binaries, except +compilation by compiling all _native_ libraries and binaries, except for we don't have `host/mrbc` directory (`host` directory itself works as placeholder for `mrbc`). Afterwards the cross compilation process proceeds like this: diff --git a/doc/guides/debugger.md b/doc/guides/debugger.md index 60be1cc8f..dba9fb57d 100644 --- a/doc/guides/debugger.md +++ b/doc/guides/debugger.md @@ -62,7 +62,7 @@ $ mrdb sample.rb You can execute the shell commands listed below: | command | description | -|:----------------:|:--------------------------------------------------------------------------| +| :--------------: | :------------------------------------------------------------------------ | | run | execute programs | | step | execute stepping | | continue | execute continuing program | @@ -83,7 +83,7 @@ You can debug the mruby binary files. #### 2.2.2.1 Debugging the binary files - notice -To debug mruby binary files, you need to compile mruby files with option `-g`. + To debug mruby binary files, you need to compile mruby files with option `-g`. ```bash $ mrbc -g sample.rb diff --git a/doc/guides/gc-arena-howto.md b/doc/guides/gc-arena-howto.md index 31bee93f1..2ac2bdfd4 100644 --- a/doc/guides/gc-arena-howto.md +++ b/doc/guides/gc-arena-howto.md @@ -4,7 +4,7 @@ _This is an English translation of [Matz's blog post][matz blog post] written in Japanese._ _Some parts are updated to reflect recent changes._ -[matz blog post]: +[matz blog post]: https://www.rubyist.net/~matz/20130731.html When you are extending mruby using C language, you may encounter mysterious "arena overflow error" or memory leak or very slow diff --git a/doc/guides/link.md b/doc/guides/link.md index 491efc413..ac19aa234 100644 --- a/doc/guides/link.md +++ b/doc/guides/link.md @@ -51,8 +51,8 @@ for example: To retrieve compiler options used to build `mruby`, you can use `mruby-config` command with following options: -- `--cc` compiler name -- `--cflags` options passed to compiler +- `--cc` compiler name +- `--cflags` options passed to compiler ```console $ mruby-config --cflags @@ -66,10 +66,10 @@ compatible to mruby configuration. To retrieve linker options, you can use `mruby-config` with following options: -- `--ld` linker name -- `--ldflags` options passed to linker -- `--ldflags-before-libs` options passed to linker before linked libraries -- `--libs` linked libraries +- `--ld` linker name +- `--ldflags` options passed to linker +- `--ldflags-before-libs` options passed to linker before linked libraries +- `--libs` linked libraries ```console $ mruby-config --ldflags diff --git a/doc/guides/mrbconf.md b/doc/guides/mrbconf.md index dc1538506..823a0ba17 100644 --- a/doc/guides/mrbconf.md +++ b/doc/guides/mrbconf.md @@ -25,7 +25,7 @@ MRuby::Build.new do |conf| end ``` -***NOTE*** +**_NOTE_** - Use common definitions (`conf.defines`) instead of per-compiler definitions (e.g., `conf.cc.defines`) unless there is a special reason not to. - It is now deprecated to edit the `include/mruby/mrbconf.h` file or give it directly as a compiler flag, as was the case before. @@ -123,7 +123,7 @@ end - Defines value is `1024`. - Specifies number of `RBasic` per each heap page. -- To calculate the number of bytes per heap page, it is "(size of management data per heap page) + (size per object) * `MRB_HEAP_PAGE_SIZE`". +- To calculate the number of bytes per heap page, it is "(size of management data per heap page) + (size per object) \* `MRB_HEAP_PAGE_SIZE`". In mruby 3.1.0, the "size of management data per heap page" is 6 words, also "size per object" is 6 words. For a 32-bit CPU, `(6 * 4) + (6 * 4) * MRB_HEAP_PAGE_SIZE` gives the bytes of size per heap page. Conversely, for example, to keep the size per heap page to 4 Ki bytes, @@ -135,7 +135,7 @@ end - Default value is `4`. - If you're allocating data types that requires alignment more than default value define the -largest value of required alignment. + largest value of required alignment. `POOL_PAGE_SIZE` @@ -149,7 +149,7 @@ largest value of required alignment. - If defined enables fixed size `mrb_state` atexit stack. - Raises `RuntimeError` when `mrb_state_atexit` call count to same `mrb_state` exceeds -`MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value. + `MRB_FIXED_STATE_ATEXIT_STACK_SIZE`'s value. `MRB_FIXED_STATE_ATEXIT_STACK_SIZE` diff --git a/doc/guides/mrbgems.md b/doc/guides/mrbgems.md index 999629d4d..fe086c1e9 100644 --- a/doc/guides/mrbgems.md +++ b/doc/guides/mrbgems.md @@ -248,7 +248,7 @@ Version requirement supports following operators: - '<=': is equal or lesser - '~>': is equal or greater and is lesser than the next major version - example 1: '~> 2.2.2' means '>= 2.2.2' and '< 2.3.0' - - example 2: '~> 2.2' means '>= 2.2.0' and '< 3.0.0' + - example 2: '~> 2.2' means '>= 2.2.0' and '< 3.0.0' When more than one version requirements is passed, the dependency must satisfy all of it. @@ -395,8 +395,8 @@ override existing classes or add new ones in this way. Put all Ruby files into the `mrblib` directory and all C files into the `src` directory. mruby codes under `mrblib` directory would be executed after gem init C -function is called. Make sure *mruby script* depends on *C code* and -*C code* doesn't depend on *mruby script*. +function is called. Make sure _mruby script_ depends on _C code_ and +_C code_ doesn't depend on _mruby script_. ### Pre-Conditions diff --git a/doc/guides/symbol.md b/doc/guides/symbol.md index c76420da9..bae789b64 100644 --- a/doc/guides/symbol.md +++ b/doc/guides/symbol.md @@ -57,13 +57,13 @@ To save RAM, `mruby` can use compile-time allocation of some symbols. You can use following macros to get preallocated symbols by including `mruby/presym.h` header. -- `MRB_SYM(xor)` //=> xor (Word characters) -- `MRB_SYM_B(xor)` //=> xor! (Method with Bang) -- `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark) -- `MRB_SYM_E(xor)` //=> xor= (Method with Equal) -- `MRB_CVSYM(xor)` //=> @@xor (Class Variable) -- `MRB_IVSYM(xor)` //=> @xor (Instance Variable) -- `MRB_OPSYM(xor)` //=> ^ (Operator) +- `MRB_SYM(xor)` //=> xor (Word characters) +- `MRB_SYM_B(xor)` //=> xor! (Method with Bang) +- `MRB_SYM_Q(xor)` //=> xor? (Method with Question mark) +- `MRB_SYM_E(xor)` //=> xor= (Method with Equal) +- `MRB_CVSYM(xor)` //=> @@xor (Class Variable) +- `MRB_IVSYM(xor)` //=> @xor (Instance Variable) +- `MRB_OPSYM(xor)` //=> ^ (Operator) For `MRB_OPSYM()`, specify the names corresponding to operators (see `MRuby::Presym::OPERATORS` in `lib/mruby/presym.rb` for the names that diff --git a/doc/internal/boxing.md b/doc/internal/boxing.md index eb03de74b..0cae591e6 100644 --- a/doc/internal/boxing.md +++ b/doc/internal/boxing.md @@ -15,7 +15,7 @@ Some values (called immediate values, e.g. integers, booleans, symbols, etc.) ar The Word boxing packing bit patterns are like following: | Types | Bit Pattern | -|--------|---------------------------------------| +| ------ | ------------------------------------- | | object | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxx000` | | fixnum | `xxxxxxxx xxxxxxxx xxxxxxxx xxxxxxx1` | | nil | `00000000 00000000 00000000 00000000` | @@ -34,7 +34,7 @@ NaN boxing packs the Ruby data in a floating-point numbers, which represent NaN The NaN boxing packing bit patterns are like following: | Types | Bit Pattern | -|--------|---------------------------------------------------------------------------| +| ------ | ------------------------------------------------------------------------- | | float | `SEEEEEEE EEEEFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF` | | +/-inf | `S1111111 11110000 00000000 00000000 00000000 00000000 00000000 00000000` | | nan | `01111111 11111000 00000000 00000000 00000000 00000000 00000000 00000000` | diff --git a/doc/mruby3.0.md b/doc/mruby3.0.md index 3f7418c49..9d211abb5 100644 --- a/doc/mruby3.0.md +++ b/doc/mruby3.0.md @@ -42,10 +42,10 @@ We have ported some new syntax from CRuby. ## Renamed for consistency Some configuration macro names are changed for consistency (use `MRB_USE_XXX` - or `MRB_NO_XXX`). +or `MRB_NO_XXX`). -| mruby2 | mruby3 | -|--------------------------------|---------------------------| +| mruby2 | mruby3 | +| ------------------------------ | ------------------------- | | `MRB_ENABLE_ALL_SYMBOLS` | `MRB_USE_ALL_SYMBOLS` | | `MRB_ENABLE_CXX_ABI` | `MRB_USE_CXX_ABI` | | `MRB_ENABLE_CXX_EXCEPTION` | `MRB_USE_CXX_EXCEPTION` | @@ -149,7 +149,8 @@ No more operand extension ## Changed Instructions -Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the address of the next instruction. +Jump addresses used to be specified by absolute offset from the start of `iseq`. Now they are relative offset from the +address of the next instruction. ## `Random` now use `xoshiro128++`. diff --git a/docker-compose.yml b/docker-compose.yml index 55b61a874..009947b0f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,4 +1,4 @@ -version: '3.8' +version: "3.8" services: test: build: diff --git a/mrbgems/mruby-bigint/README-fgmp.md b/mrbgems/mruby-bigint/README-fgmp.md index 591188c12..7693f3c1f 100644 --- a/mrbgems/mruby-bigint/README-fgmp.md +++ b/mrbgems/mruby-bigint/README-fgmp.md @@ -73,18 +73,18 @@ MS-DOS 286 C compiler (see credits above) 1. fgmp is considerably slower than gmp 2. fgmp does not implement the following: - all mpq_* - internal mpn_* functions - mpz_perfect_square_p - mpz_inp_raw, mpz_out_raw - mp_set_memory_functions, mpz_out_str, mpz_inp_str + - all mpq\_\* + - internal mpn\_\* functions + - mpz_perfect_square_p + - mpz_inp_raw, mpz_out_raw + - mp_set_memory_functions, mpz_out_str, mpz_inp_str 3. fgmp implements the following in addition to the routines in GNU gmp. - `int mpz_jacobi(MP_INT *a, MP_INT *b)` - - finds the jacobi symbol (a/b) + `int mpz_jacobi(MP_INT *a, MP_INT *b)` + - finds the jacobi symbol (a/b) 4. mpz_sizeinbase often overestimates the exact value 5. To convert your gmp based program to fgmp (subject to the -above) + above) - recompile your source. Make sure to include the gmp.h file included with fgmp rather than that included with gmp. (The point is to recompile diff --git a/mrbgems/mruby-io/README.md b/mrbgems/mruby-io/README.md index 21138ace4..99c48f3d6 100644 --- a/mrbgems/mruby-io/README.md +++ b/mrbgems/mruby-io/README.md @@ -17,7 +17,7 @@ Add the line below to your build configuration. - | method | mruby-io | memo | -|----------------------------|----------|----------| +| -------------------------- | -------- | -------- | | IO.binread | | | | IO.binwrite | | | | IO.copy_stream | | | @@ -102,7 +102,7 @@ Add the line below to your build configuration. - | method | mruby-io | memo | -|-----------------------------|----------|----------| +| --------------------------- | -------- | -------- | | File.absolute_path | | | | File.atime | | | | File.basename | o | | diff --git a/mrbgems/mruby-pack/README.md b/mrbgems/mruby-pack/README.md index 10a538095..d108f2a09 100644 --- a/mrbgems/mruby-pack/README.md +++ b/mrbgems/mruby-pack/README.md @@ -45,7 +45,7 @@ There is no dependency on other mrbgems. - V : 32-bit unsigned, VAX (little-endian) byte order - v : 16-bit unsigned, VAX (little-endian) byte order - x : null byte -- Z : same as "a", except that null is added with * +- Z : same as "a", except that null is added with \* ## License