Skip to content

Commit

Permalink
Merge branch 'main' into full-moon-0-19-0
Browse files Browse the repository at this point in the history
  • Loading branch information
Kampfkarren authored Nov 11, 2023
2 parents b7bcfa4 + 13de5c8 commit eeacd3d
Show file tree
Hide file tree
Showing 63 changed files with 1,974 additions and 130 deletions.
17 changes: 11 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Run clippy
run: cargo clippy -- -D warnings
- name: Run Rustfmt
run: cargo fmt -- --check
- uses: actions/checkout@v3
- name: Run tests (selene, all features)
run: cargo test --release -- --nocapture
working-directory: selene
Expand All @@ -31,9 +27,18 @@ jobs:
test_exhaustive_checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Install nightly for exhaustive check tests
uses: dtolnay/rust-toolchain@nightly
- name: Run exhaustive check tests
run: cargo check --features force_exhaustive_checks
working-directory: selene-lib
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Clippy
run: cargo clippy -- -D warnings
- name: Rustfmt
run: cargo fmt -- --check
if: success() || failure()
19 changes: 17 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,31 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm

## [Unreleased](https://github.com/Kampfkarren/selene/compare/0.25.0...HEAD)
### Added
- Added `table.move`to Lua 5.3 standard library
- Added `table.move` and `math.tointeger` to Lua 5.3 standard library
- Added `bit32.*` functions to Lua 5.2 standard library
- Added `table.pack`, `rawlen` and `package.config` to Lua 5.2 standard library
- Added new [`empty_loop` lint](https://kampfkarren.github.io/selene/lints/empty_loop.html), which will check for empty loop blocks.
- Added new [`roblox_suspicious_udim2_new` lint](https://kampfkarren.github.io/selene/lints/roblox_suspicious_udim2_new.html), which will warn when you pass in too few number of arguments to `UDim2.new`.
- `roblox_incorrect_roact_usage` now lints for illegal `Name` property
- Added `ignore_pattern` config to `global_usage`, which will ignore any global variables with names that match the pattern
- `roblox_incorrect_roact_usage` now checks for incorrect Roact17's `createElement` usage on variables named `React`. For Roact17 only, `key`, `children`, and `ref` are valid properties to Roblox instances.
- Excludes are now respected for single files.
- Added `no-exclude` cli flag to disable excludes.
- When given in standard library format, additional information now shows up in `incorrect_standard_library_use` missing required parameter errors.
- Added new [`mixed_table` lint](https://kampfkarren.github.io/selene/lints/mixed_table.html), which will warn against mixed tables.
- Added `bit32.byteswap` to Luau standard library
- Added `buffer` library to Luau standard library
- Added `SharedTable` to Roblox standard library

### Changed
- Updated internal parser, which includes floor division (`//`), more correct parsing of string interpolation with double braces, and better parsing of `\z` escapes.

### Fixed
- `string.pack` and `string.unpack` now have proper function signatures in the Lua 5.3 standard library.
- Moved `math.log` second argument addition from Lua 5.3 std lib to 5.2 std lib
- `undefined_variable` now correctly errors when defining multiple methods in undefined tables
- Corrected `os.exit` definition in Lua 5.2 standard library
- Fixed `manual_table_clone` incorrectly warning when loop and table are defined at different depths

## [0.25.0](https://github.com/Kampfkarren/selene/releases/tag/0.25.0) - 2023-03-12
### Added
Expand Down Expand Up @@ -401,4 +416,4 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Added standard library chaining. This means you can combine two standard libraries by setting `std` in selene.toml to `std1+std2`. You can chain as many as you want.

## [0.1.0](https://github.com/Kampfkarren/selene/releases/tag/0.1.0) - 2019-11-06
- Initial release
- Initial release
124 changes: 108 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 7 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
FROM rust:1.64-bullseye AS selene-builder
ARG RUST_VERSION="1"

FROM rust:${RUST_VERSION}-bullseye AS selene-builder
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install g++ && \
cargo install --branch main --git https://github.com/Kampfkarren/selene selene

FROM rust:1.64-bullseye AS selene-light-builder
FROM rust:${RUST_VERSION}-bullseye AS selene-light-builder
RUN apt-get update && \
apt-get upgrade -y && \
apt-get install g++ && \
cargo install --no-default-features --branch main --git https://github.com/Kampfkarren/selene selene

FROM rust:1.64-alpine3.14 AS selene-musl-builder
FROM rust:${RUST_VERSION}-alpine AS selene-musl-builder
RUN apk add g++ && \
cargo install --branch main --git https://github.com/Kampfkarren/selene selene

FROM rust:1.64-alpine3.14 AS selene-light-musl-builder
FROM rust:${RUST_VERSION}-alpine AS selene-light-musl-builder
RUN apk add g++ && \
cargo install --no-default-features --branch main --git https://github.com/Kampfkarren/selene selene

Expand All @@ -32,4 +34,4 @@ CMD ["/selene"]

FROM bash AS selene-light-musl
COPY --from=selene-light-musl-builder /usr/local/cargo/bin/selene /
CMD ["/selene"]
CMD ["/selene"]
3 changes: 3 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,21 @@
- [divide_by_zero](./lints/divide_by_zero.md)
- [duplicate_keys](./lints/duplicate_keys.md)
- [empty_if](./lints/empty_if.md)
- [empty_loop](./lints/empty_loop.md)
- [global_usage](./lints/global_usage.md)
- [high_cyclomatic_complexity](./lints/high_cyclomatic_complexity.md)
- [if_same_then_else](./lints/if_same_then_else.md)
- [ifs_same_cond](./lints/ifs_same_cond.md)
- [incorrect_standard_library_use](./lints/incorrect_standard_library_use.md)
- [manual_table_clone](./lints/manual_table_clone.md)
- [mismatched_arg_count](./lints/mismatched_arg_count.md)
- [mixed_table](./lints/mixed_table.md)
- [multiple_statements](./lints/multiple_statements.md)
- [must_use](./lints/must_use.md)
- [parenthese_conditions](./lints/parenthese_conditions.md)
- [roblox_incorrect_color3_new_bounds](./lints/roblox_incorrect_color3_new_bounds.md)
- [roblox_incorrect_roact_usage](./lints/roblox_incorrect_roact_usage.md)
- [roblox_suspicious_udim2_new](./lints/roblox_suspicious_udim2_new.md)
- [shadowing](./lints/shadowing.md)
- [suspicious_reverse_loop](./lints/suspicious_reverse_loop.md)
- [type_check_inside_call](./lints/type_check_inside_call.md)
Expand Down
3 changes: 2 additions & 1 deletion docs/src/cli/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ USAGE:
FLAGS:
--allow-warnings Pass when only warnings occur
--no-exclude Ignore excludes defined in config
-h, --help Prints help information
-n, --no-summary Suppress summary information
-q, --quiet Display only the necessary information. Equivalent to --display-style="quiet"
Expand Down Expand Up @@ -81,4 +82,4 @@ Specifies the number of threads for selene to use. Defaults to however many core

**--pattern** *pattern*

A [glob](https://en.wikipedia.org/wiki/Glob_(programming)) to match what files selene should check for. For example, if you only wanted to check files that end with `.spec.lua`, you would input `--pattern **/*.spec.lua`. Defaults to `**/*.lua`, meaning "any lua file", or `**/*.lua` and `**/*.luau` with the roblox feature flag, meaning "any lua/luau file".
A [glob](https://en.wikipedia.org/wiki/Glob_(programming)) to match what files selene should check for. For example, if you only wanted to check files that end with `.spec.lua`, you would input `--pattern **/*.spec.lua`. Defaults to `**/*.lua`, meaning "any lua file", or `**/*.lua` and `**/*.luau` with the roblox feature flag, meaning "any lua/luau file".
2 changes: 1 addition & 1 deletion docs/src/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ The first `"cool_lint"` is the name of the folder we created. The second `"cool_

Now, just run `cargo test`, and a `.stderr` file will be automatically generated! You can manipulate it however you see fit as well as modifying your lint, and so long as the file is there, selene will make sure that its accurate.

Optionally, you can add a `.std.toml` with the same name as the test next to the lua file, where you can specify a custom [standard library](./usage/std.html) to use. If you do not, the Lua 5.1 standard library will be used.
Optionally, you can add a `.std.toml` with the same name as the test next to the lua file, where you can specify a custom [standard library](./usage/std.md) to use. If you do not, the Lua 5.1 standard library will be used.

### Documenting it

Expand Down
20 changes: 20 additions & 0 deletions docs/src/lints/empty_loop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# empty_loop
## What it does
Checks for empty loop blocks.

## Why this is bad
You most likely forgot to write code in there or commented it out without commenting out the loop statement itself.

## Configuration
`comments_count` (default: `false`) - A bool that determines whether or not if statements with exclusively comments are empty.

## Example
```lua
-- Counts as an empty loop
for _ in {} do
end

for _ in {} do
-- If comments_count is true, this will not count as empty.
end
```
Loading

0 comments on commit eeacd3d

Please sign in to comment.