sonicop 26.8.107 → 26.8.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Cargo.lock +3 -3
- data/Cargo.toml +2 -2
- data/lib/sonicop/version.rb +1 -1
- data/src/cli.rs +29 -2
- data/src/engine.rs +444 -71
- data/src/magic_comment.rs +15 -9
- data/src/ruby_version.rs +1 -1
- data/src/rules/bundler/gem_comment.rs +3 -3
- data/src/rules/layout/block_end_newline.rs +14 -6
- data/src/rules/layout/closing_parenthesis_indentation.rs +7 -0
- data/src/rules/layout/condition_position.rs +6 -4
- data/src/rules/layout/element_line_breaks.rs +1 -1
- data/src/rules/layout/empty_lines_around_arguments.rs +7 -6
- data/src/rules/layout/first_array_element_indentation.rs +17 -1
- data/src/rules/layout/first_hash_element_indentation.rs +7 -4
- data/src/rules/layout/indentation_width.rs +61 -20
- data/src/rules/layout/line_length.rs +2 -2
- data/src/rules/layout/multiline_brace.rs +9 -3
- data/src/rules/layout/multiline_method_call_brace_layout.rs +3 -6
- data/src/rules/layout/space_around_block_parameters.rs +45 -14
- data/src/rules/layout/trailing_empty_lines.rs +12 -0
- data/src/rules/lint/constant_reassignment.rs +3 -0
- data/src/rules/lint/cop_directives.rs +74 -0
- data/src/rules/lint/data_define_override.rs +5 -0
- data/src/rules/lint/duplicate_methods.rs +10 -0
- data/src/rules/lint/hash_new_with_keyword_arguments_as_default.rs +5 -0
- data/src/rules/lint/incompatible_io_select_with_fiber_scheduler.rs +5 -0
- data/src/rules/lint/inherit_exception.rs +5 -0
- data/src/rules/lint/interpolation_check.rs +45 -0
- data/src/rules/lint/non_atomic_file_operation.rs +5 -0
- data/src/rules/lint/redundant_cop_enable_directive.rs +69 -75
- data/src/rules/lint/safe_navigation_consistency.rs +14 -0
- data/src/rules/lint/shared_mutable_default.rs +5 -0
- data/src/rules/lint/to_enum_arguments.rs +5 -0
- data/src/rules/lint/useless_times.rs +24 -4
- data/src/rules/mod.rs +16 -15
- data/src/rules/naming/constant_name.rs +1 -1
- data/src/rules/naming/file_name.rs +1 -1
- data/src/rules/naming/support.rs +2 -2
- data/src/rules/send_node.rs +12 -0
- data/src/rules/single_line.rs +1 -1
- data/src/rules/style/attr.rs +22 -12
- data/src/rules/style/auto_resource_cleanup.rs +6 -0
- data/src/rules/style/block_delimiters.rs +34 -16
- data/src/rules/style/class_vars.rs +6 -1
- data/src/rules/style/collection_querying.rs +15 -6
- data/src/rules/style/commented_keyword.rs +5 -5
- data/src/rules/style/comments.rs +4 -3
- data/src/rules/style/copyright.rs +1 -1
- data/src/rules/style/dir.rs +6 -0
- data/src/rules/style/document_dynamic_eval_definition.rs +6 -1
- data/src/rules/style/documentation.rs +3 -3
- data/src/rules/style/empty_literal.rs +6 -1
- data/src/rules/style/env_home.rs +6 -0
- data/src/rules/style/expand_path_arguments.rs +6 -0
- data/src/rules/style/frozen_string_literal_comment.rs +1 -1
- data/src/rules/style/hash_syntax.rs +78 -6
- data/src/rules/style/hash_transform.rs +38 -18
- data/src/rules/style/identical_conditional_branches.rs +55 -11
- data/src/rules/style/if_unless_modifier.rs +1 -1
- data/src/rules/style/in_pattern_then.rs +9 -0
- data/src/rules/style/line_length_help.rs +2 -2
- data/src/rules/style/magic_comment_format.rs +1 -1
- data/src/rules/style/map_compact_with_conditional_block.rs +36 -12
- data/src/rules/style/negated_if_else_condition.rs +20 -6
- data/src/rules/style/nested_parenthesized_calls.rs +15 -4
- data/src/rules/style/numeric_literals.rs +3 -3
- data/src/rules/style/one_line_conditional.rs +15 -3
- data/src/rules/style/or_assignment.rs +68 -44
- data/src/rules/style/parallel_assignment.rs +113 -28
- data/src/rules/style/parens.rs +81 -20
- data/src/rules/style/random_with_offset.rs +6 -0
- data/src/rules/style/redundant_array_constructor.rs +6 -0
- data/src/rules/style/redundant_line_continuation.rs +23 -4
- data/src/rules/style/redundant_parentheses.rs +33 -3
- data/src/rules/style/redundant_regexp_constructor.rs +6 -0
- data/src/rules/style/rescue_modifier.rs +32 -7
- data/src/rules/style/semicolon.rs +38 -2
- data/src/rules/style/signal_exception.rs +6 -1
- data/src/rules/style/sole_nested_conditional.rs +13 -2
- data/src/rules/style/trailing_underscore_variable.rs +12 -0
- data/src/rules/style/while_until_modifier.rs +1 -1
- data/src/rules/style/word_array.rs +16 -1
- data/src/rules/support.rs +72 -5
- data/src/rules/visibility.rs +23 -2
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bbee17a19e72bf5b5dad03303c42be9905e5dfeef68faf8f1155b5f9910f3fac
|
|
4
|
+
data.tar.gz: d756a00e368f91dcf8c3ca4d2e0e9df85c0315638d1aaa0d653e6cfbb4d68648
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cdbfc78cb9c5f22948032627bd4dbcb6f28f9b044c69d2ee139cb16b598e928113e64d3d0267505d58160b000a9a66193456cd6943fb1f95b86f8c7d1699061d
|
|
7
|
+
data.tar.gz: 6d7cf795e8e02782a81c4f16a9e2805cbd93dc88daf25d175944aefeb3b1a06af405b64c1c720129bf8945a8eee7873882968d5649efa43670d0029094e991ae
|
data/Cargo.lock
CHANGED
|
@@ -742,7 +742,7 @@ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
|
742
742
|
|
|
743
743
|
[[package]]
|
|
744
744
|
name = "sonicop"
|
|
745
|
-
version = "26.8.
|
|
745
|
+
version = "26.8.108"
|
|
746
746
|
dependencies = [
|
|
747
747
|
"anyhow",
|
|
748
748
|
"assert_cmd",
|
|
@@ -847,8 +847,8 @@ checksum = "009994f150cc0cd50ff54917d5bc8bffe8cad10ca10d81c34da2ec421ae61782"
|
|
|
847
847
|
|
|
848
848
|
[[package]]
|
|
849
849
|
name = "tree-sitter-ruby"
|
|
850
|
-
version = "26.8.
|
|
851
|
-
source = "git+https://github.com/owayo/tree-sitter-ruby.git?rev=
|
|
850
|
+
version = "26.8.101"
|
|
851
|
+
source = "git+https://github.com/owayo/tree-sitter-ruby.git?rev=f1a19bb27ba64300d1032b813c51437a5a76ea33#f1a19bb27ba64300d1032b813c51437a5a76ea33"
|
|
852
852
|
dependencies = [
|
|
853
853
|
"cc",
|
|
854
854
|
"tree-sitter-language",
|
data/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "sonicop"
|
|
3
|
-
version = "26.8.
|
|
3
|
+
version = "26.8.108"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.85"
|
|
6
6
|
description = "A fast, native RuboCop-compatible Ruby linter and formatter"
|
|
@@ -28,7 +28,7 @@ serde_yaml_ng = "0.10"
|
|
|
28
28
|
shell-words = "1.1.1"
|
|
29
29
|
tempfile = "3.27.0"
|
|
30
30
|
tree-sitter = "0.26.11"
|
|
31
|
-
tree-sitter-ruby = { git = "https://github.com/owayo/tree-sitter-ruby.git", rev = "
|
|
31
|
+
tree-sitter-ruby = { git = "https://github.com/owayo/tree-sitter-ruby.git", rev = "f1a19bb27ba64300d1032b813c51437a5a76ea33" }
|
|
32
32
|
ureq = { version = "3.4", default-features = false, features = ["native-tls"] }
|
|
33
33
|
|
|
34
34
|
[dev-dependencies]
|
data/lib/sonicop/version.rb
CHANGED
data/src/cli.rs
CHANGED
|
@@ -11,8 +11,8 @@ use crate::config::{Config, ConfigStore};
|
|
|
11
11
|
use crate::cop_name::{self, selector_matches};
|
|
12
12
|
use crate::diagnostic::{FileReport, Offense, Severity};
|
|
13
13
|
use crate::engine::{
|
|
14
|
-
CorrectMode, Selection, correct_file, discover_targets_with_store,
|
|
15
|
-
inspect_source, is_mandatory_cop, offense_count, write_corrected,
|
|
14
|
+
CorrectMode, NO_SYNTAX_GUARD, Selection, correct_file, discover_targets_with_store,
|
|
15
|
+
inspect_files_with_store, inspect_source, is_mandatory_cop, offense_count, write_corrected,
|
|
16
16
|
};
|
|
17
17
|
use crate::formatter::{
|
|
18
18
|
Format, FormatOptions, offenses_by_cop, render, smart_path, yaml_single_quoted,
|
|
@@ -359,6 +359,7 @@ fn try_run(cli: Cli, outputs: &[Option<PathBuf>]) -> Result<i32> {
|
|
|
359
359
|
validate_compatibility(&cli)?;
|
|
360
360
|
let fail_level = FailLevel::parse(&cli.fail_level)?;
|
|
361
361
|
print_deprecation_warnings(&cli);
|
|
362
|
+
warn_if_syntax_guard_disabled();
|
|
362
363
|
|
|
363
364
|
let cwd = std::env::current_dir().context("failed to determine current directory")?;
|
|
364
365
|
if cli.init {
|
|
@@ -410,6 +411,9 @@ fn try_run(cli: Cli, outputs: &[Option<PathBuf>]) -> Result<i32> {
|
|
|
410
411
|
ignore_disable_comments: cli.ignore_disable_comments,
|
|
411
412
|
display_suppressed: cli.display_suppressed,
|
|
412
413
|
correcting: cli.correct_mode() != CorrectMode::None,
|
|
414
|
+
// **No flag turns this on from the command line.** The guard is switched off for tests
|
|
415
|
+
// only, and even then per case; a run reaches the environment variable or nothing.
|
|
416
|
+
skip_syntax_guard: false,
|
|
413
417
|
};
|
|
414
418
|
let correct_mode = cli.correct_mode();
|
|
415
419
|
if !cli.list_target_files {
|
|
@@ -489,6 +493,13 @@ fn try_run(cli: Cli, outputs: &[Option<PathBuf>]) -> Result<i32> {
|
|
|
489
493
|
eprintln!("{message}");
|
|
490
494
|
run_errors += 1;
|
|
491
495
|
}
|
|
496
|
+
// Not an offense: the file on disk parses, so a reader told to look for a syntax error
|
|
497
|
+
// would find none. It is an autocorrect failure, and it has to reach the exit code --
|
|
498
|
+
// a `-A` run that silently declined to correct must not look like a clean one to CI.
|
|
499
|
+
if let Some(message) = outcome.rollback {
|
|
500
|
+
eprintln!("{message}");
|
|
501
|
+
run_errors += 1;
|
|
502
|
+
}
|
|
492
503
|
if outcome.rewritten {
|
|
493
504
|
if cli.stdin.is_some() {
|
|
494
505
|
stdin_corrected = Some(outcome.text);
|
|
@@ -609,6 +620,22 @@ fn validate_compatibility(cli: &Cli) -> Result<()> {
|
|
|
609
620
|
Ok(())
|
|
610
621
|
}
|
|
611
622
|
|
|
623
|
+
/// Says out loud that the guard against writing unparsable corrections has been switched off.
|
|
624
|
+
///
|
|
625
|
+
/// The switch exists so the guard's error rate can be measured -- with it on, the text needed to
|
|
626
|
+
/// measure it never reaches disk. **A measurement hatch must not be a silent one:** left set in a
|
|
627
|
+
/// shell profile or a CI job it turns a refusal to write into a destructive write, and nothing
|
|
628
|
+
/// else in the output would say so.
|
|
629
|
+
fn warn_if_syntax_guard_disabled() {
|
|
630
|
+
if std::env::var_os(NO_SYNTAX_GUARD).is_some() {
|
|
631
|
+
eprintln!(
|
|
632
|
+
"Sonicop: {} is set. The guard against writing corrections that do not parse is off, \
|
|
633
|
+
so autocorrection will overwrite files even when the result is a syntax error.",
|
|
634
|
+
NO_SYNTAX_GUARD
|
|
635
|
+
);
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
612
639
|
fn print_deprecation_warnings(cli: &Cli) {
|
|
613
640
|
if cli.deprecated_auto_correct {
|
|
614
641
|
eprintln!("--auto-correct is deprecated; use --autocorrect instead.");
|