sonicop 26.8.112 → 26.8.113
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 +11 -11
- data/Cargo.toml +4 -4
- data/README.ja.md +36 -23
- data/README.md +38 -26
- data/lib/sonicop/version.rb +1 -1
- data/src/config/inheritance.rs +45 -3
- data/src/engine.rs +11 -7
- data/src/lib.rs +1 -0
- data/src/nul_bytes.rs +2 -6
- data/src/parser.rs +37 -0
- data/src/profile.rs +13 -1
- data/src/rules/bundler/duplicated_group.rs +3 -2
- data/src/rules/bundler/gem_comment.rs +5 -4
- data/src/rules/gemspec/attribute_assignment.rs +4 -3
- data/src/rules/gemspec/deprecated_attribute_assignment.rs +7 -6
- data/src/rules/gemspec/duplicated_assignment.rs +4 -3
- data/src/rules/gemspec/require_mfa.rs +10 -9
- data/src/rules/gemspec/required_ruby_version.rs +3 -2
- data/src/rules/gemspec/support.rs +3 -2
- data/src/rules/layout/array_alignment.rs +1 -2
- data/src/rules/layout/block_end_newline.rs +5 -5
- data/src/rules/layout/class_structure.rs +5 -3
- data/src/rules/layout/closing_heredoc_indentation.rs +4 -3
- data/src/rules/layout/closing_parenthesis_indentation.rs +1 -2
- data/src/rules/layout/condition_position.rs +3 -2
- data/src/rules/layout/def_end_alignment.rs +2 -2
- data/src/rules/layout/dot_position.rs +1 -2
- data/src/rules/layout/empty_line_after_guard_clause.rs +3 -6
- data/src/rules/layout/empty_line_after_multiline_condition.rs +5 -5
- data/src/rules/layout/empty_lines_around_access_modifier.rs +2 -3
- data/src/rules/layout/empty_lines_around_arguments.rs +4 -4
- data/src/rules/layout/empty_lines_around_exception_handling_keywords.rs +1 -2
- data/src/rules/layout/empty_lines_around_method_body.rs +3 -2
- data/src/rules/layout/end_alignment.rs +2 -2
- data/src/rules/layout/extra_spacing.rs +7 -6
- data/src/rules/layout/first_array_element_indentation.rs +1 -2
- data/src/rules/layout/first_hash_element_indentation.rs +8 -6
- data/src/rules/layout/hash_alignment.rs +4 -4
- data/src/rules/layout/heredoc_argument_closing_parenthesis.rs +6 -5
- data/src/rules/layout/heredoc_indentation.rs +4 -3
- data/src/rules/layout/indentation_style.rs +4 -3
- data/src/rules/layout/indentation_width.rs +14 -13
- data/src/rules/layout/line_continuation_leading_space.rs +4 -3
- data/src/rules/layout/line_continuation_spacing.rs +2 -2
- data/src/rules/layout/line_length.rs +101 -57
- data/src/rules/layout/multiline_assignment_layout.rs +4 -3
- data/src/rules/layout/multiline_block_layout.rs +1 -2
- data/src/rules/layout/multiline_expression.rs +60 -31
- data/src/rules/layout/multiline_hash_brace_layout.rs +4 -3
- data/src/rules/layout/multiline_method_call_indentation.rs +1 -1
- data/src/rules/layout/multiline_operation_indentation.rs +3 -3
- data/src/rules/layout/redundant_line_break.rs +3 -2
- data/src/rules/layout/single_line_block_chain.rs +4 -3
- data/src/rules/layout/space_around_block_parameters.rs +1 -2
- data/src/rules/layout/space_around_equals_in_parameter_default.rs +1 -2
- data/src/rules/layout/space_around_operators.rs +1 -2
- data/src/rules/layout/space_before_brackets.rs +6 -5
- data/src/rules/layout/space_before_comma.rs +3 -2
- data/src/rules/layout/space_inside_range_literal.rs +8 -6
- data/src/rules/layout/support.rs +9 -7
- data/src/rules/layout/tokens.rs +15 -6
- data/src/rules/lint/access_modifier.rs +19 -10
- data/src/rules/lint/ambiguity.rs +2 -2
- data/src/rules/lint/ambiguous_block_association.rs +7 -10
- data/src/rules/lint/ambiguous_regexp_literal.rs +7 -5
- data/src/rules/lint/array_literal_in_regexp.rs +4 -3
- data/src/rules/lint/assignment_in_condition.rs +3 -2
- data/src/rules/lint/blocks.rs +2 -1
- data/src/rules/lint/boolean_symbol.rs +4 -4
- data/src/rules/lint/constant_definition_in_block.rs +1 -2
- data/src/rules/lint/constant_reassignment.rs +2 -1
- data/src/rules/lint/deprecated_open_ssl_constant.rs +1 -2
- data/src/rules/lint/disjunctive_assignment_in_constructor.rs +2 -2
- data/src/rules/lint/duplicate_branch.rs +6 -5
- data/src/rules/lint/duplicate_case_condition.rs +5 -5
- data/src/rules/lint/duplicate_hash_key.rs +4 -3
- data/src/rules/lint/duplicate_match_pattern.rs +7 -5
- data/src/rules/lint/duplicate_methods.rs +4 -3
- data/src/rules/lint/duplicate_require.rs +1 -2
- data/src/rules/lint/duplicate_set_element.rs +3 -2
- data/src/rules/lint/empty_conditional_body.rs +4 -3
- data/src/rules/lint/empty_in_pattern.rs +3 -2
- data/src/rules/lint/empty_when.rs +4 -4
- data/src/rules/lint/ensure_return.rs +3 -2
- data/src/rules/lint/float_comparison.rs +8 -6
- data/src/rules/lint/format_parameter_mismatch.rs +4 -3
- data/src/rules/lint/hash_compare_by_identity.rs +5 -4
- data/src/rules/lint/heredoc_method_call_position.rs +3 -2
- data/src/rules/lint/implicit_string_concatenation.rs +7 -5
- data/src/rules/lint/ineffective_access_modifier.rs +5 -4
- data/src/rules/lint/inherit_exception.rs +4 -3
- data/src/rules/lint/literal_as_condition.rs +5 -3
- data/src/rules/lint/literal_assignment_in_condition.rs +4 -3
- data/src/rules/lint/literal_in_interpolation.rs +5 -5
- data/src/rules/lint/literals.rs +10 -8
- data/src/rules/lint/no_return_in_begin_end_blocks.rs +2 -2
- data/src/rules/lint/node_equality.rs +8 -5
- data/src/rules/lint/non_atomic_file_operation.rs +1 -1
- data/src/rules/lint/non_deterministic_require_order.rs +5 -3
- data/src/rules/lint/non_local_exit_from_iterator.rs +3 -2
- data/src/rules/lint/number_conversion.rs +1 -1
- data/src/rules/lint/out_of_range_regexp_ref.rs +6 -4
- data/src/rules/lint/redundant_dir_glob_sort.rs +1 -2
- data/src/rules/lint/redundant_safe_navigation.rs +4 -3
- data/src/rules/lint/redundant_splat_expansion.rs +4 -2
- data/src/rules/lint/redundant_string_coercion.rs +3 -2
- data/src/rules/lint/regexp_source.rs +2 -2
- data/src/rules/lint/require_range_parentheses.rs +5 -5
- data/src/rules/lint/rescue_exception.rs +4 -3
- data/src/rules/lint/rescue_type.rs +3 -2
- data/src/rules/lint/return_in_void_context.rs +2 -2
- data/src/rules/lint/safe_navigation_chain.rs +3 -2
- data/src/rules/lint/self_assignment.rs +3 -2
- data/src/rules/lint/shadowed_argument.rs +2 -2
- data/src/rules/lint/shadowed_exception.rs +2 -2
- data/src/rules/lint/suppressed_exception_in_number_conversion.rs +4 -3
- data/src/rules/lint/symbol_conversion.rs +6 -5
- data/src/rules/lint/syntax.rs +4 -3
- data/src/rules/lint/triple_quotes.rs +3 -2
- data/src/rules/lint/unescaped_bracket_in_regexp.rs +1 -1
- data/src/rules/lint/unexpected_block_arity.rs +3 -2
- data/src/rules/lint/unmodified_reduce_accumulator.rs +7 -6
- data/src/rules/lint/unreachable_pattern_branch.rs +4 -4
- data/src/rules/lint/unused_block_argument.rs +2 -2
- data/src/rules/lint/unused_method_argument.rs +1 -2
- data/src/rules/lint/useless_assignment.rs +3 -2
- data/src/rules/lint/useless_constant_scoping.rs +3 -2
- data/src/rules/lint/useless_else_without_rescue.rs +4 -3
- data/src/rules/lint/useless_rescue.rs +5 -4
- data/src/rules/lint/useless_ruby2_keywords.rs +2 -1
- data/src/rules/lint/useless_setter_call.rs +5 -4
- data/src/rules/lint/useless_times.rs +4 -3
- data/src/rules/lint/variable_force.rs +146 -100
- data/src/rules/lint/void.rs +5 -4
- data/src/rules/metrics/block_nesting.rs +1 -2
- data/src/rules/metrics/collection_literal_length.rs +2 -1
- data/src/rules/metrics/complexity.rs +18 -13
- data/src/rules/metrics/fragments.rs +10 -14
- data/src/rules/metrics/locals.rs +23 -12
- data/src/rules/metrics/parameter_lists.rs +7 -6
- data/src/rules/metrics/support.rs +1 -1
- data/src/rules/mod.rs +464 -62
- data/src/rules/naming/ascii_identifiers.rs +3 -3
- data/src/rules/naming/block_forwarding.rs +9 -8
- data/src/rules/naming/constant_name.rs +1 -1
- data/src/rules/naming/predicate_method.rs +6 -5
- data/src/rules/naming/predicate_prefix.rs +10 -8
- data/src/rules/naming/rescued_exceptions_variable_name.rs +8 -6
- data/src/rules/naming/support.rs +7 -5
- data/src/rules/naming/variable_number.rs +4 -4
- data/src/rules/node_ext.rs +1 -1
- data/src/rules/ruby_literal.rs +3 -2
- data/src/rules/security/compound_hash.rs +3 -2
- data/src/rules/security/open.rs +5 -4
- data/src/rules/send_node.rs +134 -0
- data/src/rules/single_line.rs +4 -4
- data/src/rules/style/access_modifier_declarations.rs +1 -1
- data/src/rules/style/alias.rs +1 -2
- data/src/rules/style/and_or.rs +2 -2
- data/src/rules/style/arguments_forwarding.rs +5 -5
- data/src/rules/style/array_coercion.rs +5 -5
- data/src/rules/style/array_first_last.rs +3 -3
- data/src/rules/style/array_intersect.rs +2 -2
- data/src/rules/style/array_intersect_with_single_element.rs +1 -1
- data/src/rules/style/attr.rs +1 -1
- data/src/rules/style/auto_resource_cleanup.rs +1 -1
- data/src/rules/style/bitwise_predicate.rs +2 -2
- data/src/rules/style/block_args.rs +1 -1
- data/src/rules/style/block_delimiters.rs +7 -6
- data/src/rules/style/case_equality.rs +3 -2
- data/src/rules/style/case_like_if.rs +1 -1
- data/src/rules/style/class_and_module_children.rs +7 -5
- data/src/rules/style/class_methods.rs +1 -1
- data/src/rules/style/collection_compact.rs +4 -4
- data/src/rules/style/combinable_defined.rs +2 -2
- data/src/rules/style/combinable_loops.rs +1 -1
- data/src/rules/style/comparable_clamp.rs +2 -2
- data/src/rules/style/concat_array_literals.rs +3 -3
- data/src/rules/style/conditional.rs +8 -1
- data/src/rules/style/constant_visibility.rs +3 -3
- data/src/rules/style/copyright.rs +1 -1
- data/src/rules/style/data_inheritance.rs +1 -1
- data/src/rules/style/def_with_parentheses.rs +1 -1
- data/src/rules/style/document_dynamic_eval_definition.rs +1 -1
- data/src/rules/style/documentation.rs +1 -1
- data/src/rules/style/each_for_simple_loop.rs +1 -1
- data/src/rules/style/each_with_object.rs +4 -4
- data/src/rules/style/empty_block_parameter.rs +1 -1
- data/src/rules/style/empty_case_condition.rs +6 -6
- data/src/rules/style/empty_class_definition.rs +1 -1
- data/src/rules/style/empty_else.rs +1 -1
- data/src/rules/style/empty_heredoc.rs +1 -1
- data/src/rules/style/empty_lambda_parameter.rs +1 -1
- data/src/rules/style/empty_literal.rs +2 -2
- data/src/rules/style/empty_method.rs +1 -1
- data/src/rules/style/empty_string_inside_interpolation.rs +1 -1
- data/src/rules/style/endless.rs +1 -1
- data/src/rules/style/env_home.rs +1 -1
- data/src/rules/style/even_odd.rs +1 -1
- data/src/rules/style/exact_regexp_match.rs +1 -1
- data/src/rules/style/expand_path_arguments.rs +3 -3
- data/src/rules/style/explicit_block_argument.rs +3 -3
- data/src/rules/style/file_open_call.rs +3 -3
- data/src/rules/style/file_write.rs +1 -1
- data/src/rules/style/for.rs +1 -1
- data/src/rules/style/format_string.rs +2 -2
- data/src/rules/style/format_string_token.rs +6 -6
- data/src/rules/style/guard_clause.rs +8 -7
- data/src/rules/style/hash_as_last_array_item.rs +4 -4
- data/src/rules/style/hash_each_methods.rs +1 -1
- data/src/rules/style/hash_like_case.rs +8 -8
- data/src/rules/style/hash_lookup_method.rs +3 -3
- data/src/rules/style/hash_subset.rs +16 -10
- data/src/rules/style/hash_syntax.rs +4 -4
- data/src/rules/style/hash_transform.rs +20 -18
- data/src/rules/style/identical_conditional_branches.rs +4 -5
- data/src/rules/style/if_inside_else.rs +3 -3
- data/src/rules/style/if_unless_modifier.rs +13 -14
- data/src/rules/style/if_with_boolean_literal_branches.rs +1 -1
- data/src/rules/style/if_with_semicolon.rs +1 -1
- data/src/rules/style/in_pattern_then.rs +2 -2
- data/src/rules/style/inverse_methods.rs +2 -2
- data/src/rules/style/invertible_unless_condition.rs +3 -3
- data/src/rules/style/it_block_parameter.rs +1 -1
- data/src/rules/style/keyword_arguments_merging.rs +2 -2
- data/src/rules/style/keyword_parameters_order.rs +1 -1
- data/src/rules/style/magic_comment_format.rs +3 -2
- data/src/rules/style/map_chain.rs +1 -1
- data/src/rules/style/map_compact_with_conditional_block.rs +3 -3
- data/src/rules/style/map_into_array.rs +7 -7
- data/src/rules/style/map_join.rs +3 -3
- data/src/rules/style/method_call_with_args_parentheses.rs +7 -7
- data/src/rules/style/method_call_without_args_parentheses.rs +2 -2
- data/src/rules/style/method_def_parentheses.rs +2 -3
- data/src/rules/style/min_max.rs +3 -3
- data/src/rules/style/min_max_comparison.rs +2 -2
- data/src/rules/style/missing_else.rs +1 -1
- data/src/rules/style/missing_respond_to_missing.rs +1 -1
- data/src/rules/style/mixin_grouping.rs +1 -1
- data/src/rules/style/multiline_block_chain.rs +2 -2
- data/src/rules/style/multiline_if_then.rs +1 -1
- data/src/rules/style/multiline_in_pattern_then.rs +1 -1
- data/src/rules/style/multiline_method_signature.rs +1 -1
- data/src/rules/style/multiline_when_then.rs +2 -2
- data/src/rules/style/mutable_constant.rs +3 -3
- data/src/rules/style/negated_if.rs +2 -2
- data/src/rules/style/negated_if_else_condition.rs +2 -2
- data/src/rules/style/negated_while.rs +1 -1
- data/src/rules/style/negative_array_index.rs +2 -2
- data/src/rules/style/nested_modifier.rs +1 -1
- data/src/rules/style/nested_parenthesized_calls.rs +2 -2
- data/src/rules/style/nested_ternary_operator.rs +2 -2
- data/src/rules/style/next.rs +1 -1
- data/src/rules/style/nil_lambda.rs +2 -2
- data/src/rules/style/nodes.rs +21 -0
- data/src/rules/style/non_nil_check.rs +2 -2
- data/src/rules/style/numbered_parameters_limit.rs +2 -2
- data/src/rules/style/one_line_conditional.rs +4 -4
- data/src/rules/style/optional_arguments.rs +1 -1
- data/src/rules/style/or_assignment.rs +1 -1
- data/src/rules/style/parallel_assignment.rs +9 -10
- data/src/rules/style/parens.rs +1 -1
- data/src/rules/style/parentheses_around_condition.rs +3 -3
- data/src/rules/style/partition_instead_of_double_select.rs +3 -3
- data/src/rules/style/percent.rs +9 -7
- data/src/rules/style/percent_q_literals.rs +4 -3
- data/src/rules/style/preferred_hash_methods.rs +1 -1
- data/src/rules/style/random_with_offset.rs +1 -1
- data/src/rules/style/reduce_to_hash.rs +6 -6
- data/src/rules/style/redundant_argument.rs +1 -1
- data/src/rules/style/redundant_assignment.rs +5 -5
- data/src/rules/style/redundant_begin.rs +2 -2
- data/src/rules/style/redundant_capital_w.rs +3 -2
- data/src/rules/style/redundant_condition.rs +9 -7
- data/src/rules/style/redundant_current_directory_in_path.rs +2 -2
- data/src/rules/style/redundant_double_splat_hash_braces.rs +4 -4
- data/src/rules/style/redundant_file_extension_in_require.rs +2 -2
- data/src/rules/style/redundant_format.rs +16 -14
- data/src/rules/style/redundant_freeze.rs +1 -1
- data/src/rules/style/redundant_heredoc_delimiter_quotes.rs +1 -1
- data/src/rules/style/redundant_initialize.rs +2 -2
- data/src/rules/style/redundant_interpolation.rs +2 -2
- data/src/rules/style/redundant_interpolation_unfreeze.rs +2 -2
- data/src/rules/style/redundant_line_continuation.rs +5 -4
- data/src/rules/style/redundant_parentheses.rs +16 -15
- data/src/rules/style/redundant_regexp_argument.rs +1 -1
- data/src/rules/style/redundant_regexp_character_class.rs +4 -3
- data/src/rules/style/redundant_regexp_escape.rs +3 -2
- data/src/rules/style/redundant_return.rs +1 -2
- data/src/rules/style/redundant_self.rs +11 -11
- data/src/rules/style/redundant_sort.rs +1 -1
- data/src/rules/style/redundant_sort_by.rs +1 -1
- data/src/rules/style/redundant_string_escape.rs +6 -5
- data/src/rules/style/regexp_literal.rs +3 -2
- data/src/rules/style/require_order.rs +2 -2
- data/src/rules/style/rescue_modifier.rs +1 -1
- data/src/rules/style/rescue_standard_error.rs +1 -1
- data/src/rules/style/return_nil.rs +2 -2
- data/src/rules/style/return_nil_in_predicate_method_definition.rs +2 -2
- data/src/rules/style/safe_navigation.rs +2 -2
- data/src/rules/style/sample.rs +3 -3
- data/src/rules/style/select_by.rs +2 -2
- data/src/rules/style/select_by_range.rs +1 -1
- data/src/rules/style/semicolon.rs +5 -4
- data/src/rules/style/single_argument_dig.rs +1 -1
- data/src/rules/style/single_line_block_params.rs +7 -6
- data/src/rules/style/single_line_do_end_block.rs +13 -12
- data/src/rules/style/single_line_methods.rs +2 -2
- data/src/rules/style/slicing_with_range.rs +2 -2
- data/src/rules/style/sole_nested_conditional.rs +4 -4
- data/src/rules/style/special_global_vars.rs +2 -2
- data/src/rules/style/stabby_lambda_parentheses.rs +1 -1
- data/src/rules/style/statement_modifier.rs +3 -2
- data/src/rules/style/static_class.rs +1 -1
- data/src/rules/style/string_concatenation.rs +9 -7
- data/src/rules/style/string_hash_keys.rs +3 -2
- data/src/rules/style/string_literals.rs +3 -3
- data/src/rules/style/string_literals_in_interpolation.rs +1 -1
- data/src/rules/style/struct_inheritance.rs +3 -3
- data/src/rules/style/super_arguments.rs +2 -2
- data/src/rules/style/super_with_args_parentheses.rs +1 -1
- data/src/rules/style/swap_values.rs +1 -1
- data/src/rules/style/symbol_array.rs +1 -1
- data/src/rules/style/symbol_proc.rs +3 -3
- data/src/rules/style/tally_method.rs +4 -4
- data/src/rules/style/ternary_parentheses.rs +4 -4
- data/src/rules/style/top_level_method_definition.rs +1 -1
- data/src/rules/style/trailing_body.rs +1 -1
- data/src/rules/style/trailing_comma_in_array_literal.rs +1 -1
- data/src/rules/style/trailing_comma_in_hash_literal.rs +1 -1
- data/src/rules/style/trailing_method_end_statement.rs +1 -1
- data/src/rules/style/trailing_underscore_variable.rs +4 -5
- data/src/rules/style/trivial_accessors.rs +2 -2
- data/src/rules/style/unless_logical_operators.rs +1 -1
- data/src/rules/style/unpack_first.rs +1 -1
- data/src/rules/style/when_then.rs +4 -4
- data/src/rules/style/while_until_do.rs +1 -1
- data/src/rules/style/while_until_modifier.rs +3 -3
- data/src/rules/style/word_array.rs +3 -3
- data/src/rules/style/yoda_condition.rs +2 -2
- data/src/rules/support.rs +33 -8
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 60de249d7f58e674b388a3514790bbaf79f4fc4ce59338d281b1684fbe124bd2
|
|
4
|
+
data.tar.gz: afe8bb37e97f4c4043825877ca906d79e7511dc98e1ac6270a8b2d84a3824f30
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 856f0aab5b6a28b07ddc026d2513b9415f7b50b3697b1e256667796683b929dade0950e22b71dc90259d98ab6ef5ffb43f5db7ab059e2d3948deacdafc080251
|
|
7
|
+
data.tar.gz: ebfba527d38101fec7b231c916dfb5ee3c47f602da107a555a8a7df56c1393c4c2ed968f1f113881a73a723cd8136593e7c1e304ffd81fe52b2e1795ff216d7e
|
data/Cargo.lock
CHANGED
|
@@ -128,9 +128,9 @@ dependencies = [
|
|
|
128
128
|
|
|
129
129
|
[[package]]
|
|
130
130
|
name = "bstr"
|
|
131
|
-
version = "1.13.
|
|
131
|
+
version = "1.13.1"
|
|
132
132
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
133
|
-
checksum = "
|
|
133
|
+
checksum = "6bb31b46c14244e20ee9984b11bf5c992b91fb6939fea616e3512c8baecdbe5f"
|
|
134
134
|
dependencies = [
|
|
135
135
|
"memchr",
|
|
136
136
|
"regex-automata",
|
|
@@ -145,9 +145,9 @@ checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
|
|
|
145
145
|
|
|
146
146
|
[[package]]
|
|
147
147
|
name = "cc"
|
|
148
|
-
version = "1.4.
|
|
148
|
+
version = "1.4.3"
|
|
149
149
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
150
|
-
checksum = "
|
|
150
|
+
checksum = "509591b7bcd67f4ef775afad7662703b4935daaa6ec0e5605cfb1090b32a2b6d"
|
|
151
151
|
dependencies = [
|
|
152
152
|
"find-msvc-tools",
|
|
153
153
|
"shlex",
|
|
@@ -317,9 +317,9 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
|
|
|
317
317
|
|
|
318
318
|
[[package]]
|
|
319
319
|
name = "find-msvc-tools"
|
|
320
|
-
version = "0.1.
|
|
320
|
+
version = "0.1.11"
|
|
321
321
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
322
|
-
checksum = "
|
|
322
|
+
checksum = "d45db016d36b838f563236e9193d0ee6ce38f3f68b6c94e914b4929c96bbb890"
|
|
323
323
|
|
|
324
324
|
[[package]]
|
|
325
325
|
name = "foreign-types"
|
|
@@ -549,9 +549,9 @@ checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"
|
|
|
549
549
|
|
|
550
550
|
[[package]]
|
|
551
551
|
name = "pkg-config"
|
|
552
|
-
version = "0.3.
|
|
552
|
+
version = "0.3.34"
|
|
553
553
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
554
|
-
checksum = "
|
|
554
|
+
checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
|
|
555
555
|
|
|
556
556
|
[[package]]
|
|
557
557
|
name = "predicates"
|
|
@@ -793,7 +793,7 @@ checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
|
|
793
793
|
|
|
794
794
|
[[package]]
|
|
795
795
|
name = "sonicop"
|
|
796
|
-
version = "26.8.
|
|
796
|
+
version = "26.8.113"
|
|
797
797
|
dependencies = [
|
|
798
798
|
"anyhow",
|
|
799
799
|
"assert_cmd",
|
|
@@ -880,9 +880,9 @@ checksum = "8f50febec83f5ee1df3015341d8bd429f2d1cc62bcba7ea2076759d315084683"
|
|
|
880
880
|
|
|
881
881
|
[[package]]
|
|
882
882
|
name = "tree-sitter"
|
|
883
|
-
version = "0.26.
|
|
883
|
+
version = "0.26.12"
|
|
884
884
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
885
|
-
checksum = "
|
|
885
|
+
checksum = "83c567a8e18ae93f20982c90370b16fd24023aeaf52f6052b96957ab253a0fec"
|
|
886
886
|
dependencies = [
|
|
887
887
|
"cc",
|
|
888
888
|
"regex",
|
data/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "sonicop"
|
|
3
|
-
version = "26.8.
|
|
3
|
+
version = "26.8.113"
|
|
4
4
|
edition = "2024"
|
|
5
5
|
rust-version = "1.85"
|
|
6
6
|
description = "A fast, native RuboCop-compatible Ruby linter and formatter"
|
|
@@ -29,7 +29,7 @@ serde_json = "1.0.151"
|
|
|
29
29
|
serde_yaml_ng = "0.10"
|
|
30
30
|
shell-words = "1.1.1"
|
|
31
31
|
tempfile = "3.27.0"
|
|
32
|
-
tree-sitter = "0.26.
|
|
32
|
+
tree-sitter = "0.26.12"
|
|
33
33
|
tree-sitter-ruby = { git = "https://github.com/owayo/tree-sitter-ruby.git", tag = "v26.8.103" }
|
|
34
34
|
ureq = { version = "3.4", default-features = false, features = ["native-tls"] }
|
|
35
35
|
|
|
@@ -44,8 +44,8 @@ lto = "thin"
|
|
|
44
44
|
codegen-units = 1
|
|
45
45
|
strip = true
|
|
46
46
|
|
|
47
|
-
# `cargo build --profile profiling`
|
|
48
|
-
#
|
|
47
|
+
# `cargo build --profile profiling` はサンプリングプロファイラ用のシンボルを残しつつ、
|
|
48
|
+
# `--release` と同じ最適化コードを生成する。
|
|
49
49
|
[profile.profiling]
|
|
50
50
|
inherits = "release"
|
|
51
51
|
debug = 1
|
data/README.ja.md
CHANGED
|
@@ -153,6 +153,8 @@ sonicop --show-cops
|
|
|
153
153
|
`AllCops/DisabledByDefault`、`Include`/`Exclude`、Cop ごとの `Enabled`、`Exclude`、
|
|
154
154
|
`Severity`、`Safe`、`SafeAutoCorrect` と設定値に対応します。宣言されたプラグイン由来の
|
|
155
155
|
Cop は「認識済み・未実装」として受理し、Ruby プラグインコード自体は実行しません。
|
|
156
|
+
リモート設定のリクエストには 30 秒のネットワークタイムアウトを設け、応答は 1 件あたり
|
|
157
|
+
5 MiB に制限します。
|
|
156
158
|
|
|
157
159
|
```yaml
|
|
158
160
|
inherit_from: .rubocop_todo.yml
|
|
@@ -229,52 +231,63 @@ autocorrect は RuboCop 自身のツリーと Mastodon でバイト単位に一
|
|
|
229
231
|
既定の実行はどちらの群にも届きません。)
|
|
230
232
|
各値は暖機後 2 回の最速値です。
|
|
231
233
|
|
|
232
|
-
| コーパス | ファイル | RuboCop 並列 | Sonicop 並列 | RuboCop 単一 | Sonicop 単一 |
|
|
233
|
-
|
|
234
|
-
| rubocop/rubocop | 1,
|
|
235
|
-
| mastodon/mastodon | 3,
|
|
236
|
-
| Homebrew/brew | 2,
|
|
237
|
-
| rails/rails | 3,
|
|
238
|
-
| ruby/ruby | 7,
|
|
234
|
+
| コーパス | ファイル | offense | RuboCop 並列 | Sonicop 並列 | RuboCop 単一 | Sonicop 単一 |
|
|
235
|
+
|---|---:|---:|---:|---:|---:|---:|
|
|
236
|
+
| rubocop/rubocop | 1,780 | 5,826 | 10.85 秒 | **1.53 秒** | 41.44 秒 | **8.96 秒** |
|
|
237
|
+
| mastodon/mastodon | 3,292 | 15,293 | 22.59 秒 | **3.04 秒** | 34.74 秒 | **6.86 秒** |
|
|
238
|
+
| Homebrew/brew | 2,296 | 51,527 | 13.56 秒 | **2.21 秒** | 40.36 秒 | **6.51 秒** |
|
|
239
|
+
| rails/rails | 3,562 | 168,615 | 32.90 秒 | **8.84 秒** | 85.71 秒 | **19.17 秒** |
|
|
240
|
+
| ruby/ruby | 7,477 | 765,975 | 86.89 秒 | **15.59 秒** | 193.59 秒 | **37.98 秒** |
|
|
239
241
|
|
|
240
|
-
差は並列で
|
|
242
|
+
差は並列で 3.7〜7.4 倍、単一プロセスで 4.5〜6.2 倍と幅があり、1 コーパスでは代表できません。
|
|
241
243
|
**単一プロセスの列を読み、並列は目安として扱ってください。** 同じ 2 つのバイナリを 1 日に
|
|
242
244
|
3 回測ったところ、単一プロセスの値は毎回 16% 以内に収まったのに対し、RuboCop 自身のツリーでの
|
|
243
245
|
並列の倍率は、マシンが他に何をしていたかだけで 3.3 倍から 9.2 倍まで動きました。単一プロセスは
|
|
244
246
|
エンジンを測っていますが、並列はエンジンに加えて「その実行でスケジューリングがそのツリーに
|
|
245
247
|
どれだけ噛み合ったか」を測っています。
|
|
246
248
|
|
|
247
|
-
仕事を省いて速いわけではありません。この同じ 394 Cop
|
|
248
|
-
|
|
249
|
-
|
|
249
|
+
仕事を省いて速いわけではありません。この同じ 394 Cop について、表のどのコーパスでも
|
|
250
|
+
**offense の総数が一致**し、RuboCop 自身のツリーと Mastodon ではその 1 件ずつが同じ位置・
|
|
251
|
+
同じメッセージ・同じ severity です。Rails は 168,615 件のうち 2 件だけ食い違います
|
|
252
|
+
(Sonicop が出す `Style/CaseLikeIf` 1 件と、出さない `Metrics/AbcSize` 1 件)。
|
|
253
|
+
RuboCop 自身のツリーでは 1 件の `correctable` フラグが違います。
|
|
254
|
+
autocorrect は前者と後者でバイト単位に一致します。
|
|
250
255
|
|
|
251
|
-
再現時に注意が必要な点が
|
|
256
|
+
再現時に注意が必要な点が 4 つあります。RuboCop は **`--cache false` と併用すると
|
|
252
257
|
`--parallel` を黙って無効化します**。そのためここでの並列実行はキャッシュを有効にしたうえで
|
|
253
258
|
実行ごとにキャッシュディレクトリを消しており、`--cache false --parallel` で計測すると
|
|
254
259
|
単一プロセスを測ることになり差が過大に出ます。また RuboCop の既定は単一プロセス、
|
|
255
260
|
Sonicop は `--no-parallel` を渡さない限り並列です。そして**両方ともキャッシュを空にする**
|
|
256
261
|
必要があります。Sonicop も既定でキャッシュするため、同じツリーを 2 回目に流すと自分の
|
|
257
262
|
キャッシュが答えてしまい、エンジンについては何も測れません。どちらにも使い捨ての
|
|
258
|
-
|
|
263
|
+
キャッシュディレクトリを渡してください。最後に、そのキャッシュディレクトリは**実パス**である
|
|
264
|
+
必要があります。macOS の `mktemp -d` は `/var/folders/…` を返し、その `/var` は symlink なので
|
|
265
|
+
RuboCop はそこを拒み、キャッシュ無しで走ってしまいます。
|
|
259
266
|
|
|
260
267
|
```bash
|
|
261
268
|
# RuboCop(並列・キャッシュは毎回空・既定の全 394 Cop)
|
|
262
|
-
|
|
269
|
+
root=$(mktemp -d /private/tmp/bench.XXXXXX)
|
|
270
|
+
rubocop --force-default-config --cache true --cache-root "$root" \
|
|
263
271
|
--no-color --parallel -f quiet
|
|
264
272
|
|
|
265
273
|
# Sonicop(キャッシュは毎回空)
|
|
266
|
-
sonicop --force-default-config --cache-root "$
|
|
274
|
+
sonicop --force-default-config --cache-root "$root" --format quiet
|
|
267
275
|
```
|
|
268
276
|
|
|
277
|
+
キャッシュの書き込みもこの数値に含まれており、無料ではありません。索引は全 offense を
|
|
278
|
+
「見つかった行のテキスト」付きで保持するため、`ruby/ruby` では 336 MB になります。
|
|
279
|
+
2 回目の実行(キャッシュ命中)は `ruby/ruby` で 1.59 秒、Rails で 0.42 秒です。
|
|
280
|
+
|
|
269
281
|
測定機は Apple M2(8 コア)、Ruby 4.0.6(YJIT 利用可)、RubyGems 導入の RuboCop 1.89.0。
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
282
|
+
2026-08-31 に、`rubocop_rubocop` 2693129 / `mastodon_mastodon` b59ddc7 / `Homebrew_brew` b42173b /
|
|
283
|
+
`rails_rails` a19f07f / `ruby_ruby` 22e4a75 の各リビジョンに対して測定しました。
|
|
284
|
+
1 分平均のロードアベレージは各行の測定時点で 4.5〜7.1 で、その大半は RuboCop 自身の並列
|
|
285
|
+
ワーカーです(計測する以上避けられません)。**アイドル状態ではありません。**
|
|
286
|
+
各コーパスで両者を連続して同じ条件で測っているため倍率は保たれますが、秒数そのものは下限ではなく、
|
|
287
|
+
静かなマシンならより速く出ます。コアを奪い合うものが動いていると両者とも膨らみ、その度合いは
|
|
288
|
+
一致しません。それが並列の列があれだけ動く理由です。秒数そのものが重要なときは、他に負荷のない
|
|
289
|
+
状態で測り、**実行の前後でロードアベレージを記録してください** — その情報が無い数値は、
|
|
290
|
+
別の数値と比べられません。
|
|
278
291
|
|
|
279
292
|
## 開発
|
|
280
293
|
|
data/README.md
CHANGED
|
@@ -160,6 +160,8 @@ run. Local and HTTPS `inherit_from`, `inherit_gem`, `inherit_mode`,
|
|
|
160
160
|
`AllCops/DisabledByDefault`, `Include`, and `Exclude`, plus per-cop `Enabled`, `Exclude`,
|
|
161
161
|
`Severity`, `Safe`, `SafeAutoCorrect`, and cop settings are supported. Cops supplied by declared
|
|
162
162
|
plugins are accepted as recognized-but-unimplemented without executing Ruby plugin code.
|
|
163
|
+
Remote configuration requests use 30-second network timeouts, and each response is limited to
|
|
164
|
+
5 MiB.
|
|
163
165
|
|
|
164
166
|
```yaml
|
|
165
167
|
inherit_from: .rubocop_todo.yml
|
|
@@ -240,52 +242,62 @@ once the 159 RuboCop ships as `Enabled: pending` and the 56 it ships as `Enabled
|
|
|
240
242
|
aside; a default run reaches neither group on either side.) Times are the fastest of two
|
|
241
243
|
warmed runs.
|
|
242
244
|
|
|
243
|
-
| Corpus | Files | RuboCop parallel | Sonicop parallel | RuboCop single | Sonicop single |
|
|
244
|
-
|
|
245
|
-
| rubocop/rubocop | 1,
|
|
246
|
-
| mastodon/mastodon | 3,
|
|
247
|
-
| Homebrew/brew | 2,
|
|
248
|
-
| rails/rails | 3,
|
|
249
|
-
| ruby/ruby | 7,
|
|
245
|
+
| Corpus | Files | Offenses | RuboCop parallel | Sonicop parallel | RuboCop single | Sonicop single |
|
|
246
|
+
|---|---:|---:|---:|---:|---:|---:|
|
|
247
|
+
| rubocop/rubocop | 1,780 | 5,826 | 10.85 s | **1.53 s** | 41.44 s | **8.96 s** |
|
|
248
|
+
| mastodon/mastodon | 3,292 | 15,293 | 22.59 s | **3.04 s** | 34.74 s | **6.86 s** |
|
|
249
|
+
| Homebrew/brew | 2,296 | 51,527 | 13.56 s | **2.21 s** | 40.36 s | **6.51 s** |
|
|
250
|
+
| rails/rails | 3,562 | 168,615 | 32.90 s | **8.84 s** | 85.71 s | **19.17 s** |
|
|
251
|
+
| ruby/ruby | 7,477 | 765,975 | 86.89 s | **15.59 s** | 193.59 s | **37.98 s** |
|
|
250
252
|
|
|
251
|
-
The gap is
|
|
253
|
+
The gap is 3.7x to 7.4x in parallel and 4.5x to 6.2x single-process, so no single corpus summarizes
|
|
252
254
|
it. **Read the single-process column and treat the parallel one as indicative.** Measuring the same
|
|
253
255
|
two binaries three times over a day put the single-process figures within 16% of each other every
|
|
254
256
|
time, while the parallel ratio on RuboCop's own tree moved between 3.3x and 9.2x purely with what
|
|
255
257
|
else the machine was doing. Single-process measures the engines; parallel measures the engines plus
|
|
256
258
|
how well each one's scheduling happens to fit that tree on that run.
|
|
257
259
|
|
|
258
|
-
The speed is not bought by skipping work
|
|
259
|
-
on
|
|
260
|
-
|
|
260
|
+
The speed is not bought by skipping work. Over those same 394 cops the two find the **same number of
|
|
261
|
+
offenses** on every corpus in the table, and on RuboCop's own tree and on Mastodon every one of them
|
|
262
|
+
is at the same position with the same message and severity. Rails, at 168,615 offenses, differs in
|
|
263
|
+
two of them — one `Style/CaseLikeIf` Sonicop reports and one `Metrics/AbcSize` it does not — and
|
|
264
|
+
RuboCop's own tree differs in one offense's `correctable` flag. Autocorrect is byte-identical on the
|
|
265
|
+
first and the last.
|
|
261
266
|
|
|
262
|
-
|
|
267
|
+
Four details matter for reproducing this. RuboCop **silently turns `--parallel` off when combined
|
|
263
268
|
with `--cache false`**, so its parallel runs here use a cache directory that is deleted before each
|
|
264
269
|
run rather than disabled; timing it with `--cache false --parallel` measures a single process and
|
|
265
270
|
overstates the difference. RuboCop's default is a single process, while Sonicop is parallel unless
|
|
266
|
-
`--no-parallel` is passed.
|
|
267
|
-
second run over the same tree answers from its own cache and measures nothing about the engine
|
|
268
|
-
|
|
271
|
+
`--no-parallel` is passed. Both sides need a **cold** cache: Sonicop caches by default too, so a
|
|
272
|
+
second run over the same tree answers from its own cache and measures nothing about the engine —
|
|
273
|
+
give each tool a throwaway cache root. And the cache root must be a **real path**: macOS `mktemp -d`
|
|
274
|
+
returns `/var/folders/…`, whose `/var` is a symlink, and RuboCop refuses such a location and runs
|
|
275
|
+
with no cache at all.
|
|
269
276
|
|
|
270
277
|
```bash
|
|
271
278
|
# RuboCop, parallel, cold cache, its full default set of 394 cops
|
|
272
|
-
|
|
279
|
+
root=$(mktemp -d /private/tmp/bench.XXXXXX)
|
|
280
|
+
rubocop --force-default-config --cache true --cache-root "$root" \
|
|
273
281
|
--no-color --parallel -f quiet
|
|
274
282
|
|
|
275
283
|
# Sonicop, cold cache
|
|
276
|
-
sonicop --force-default-config --cache-root "$
|
|
284
|
+
sonicop --force-default-config --cache-root "$root" --format quiet
|
|
277
285
|
```
|
|
278
286
|
|
|
287
|
+
Writing the cache is part of these numbers, and it is not free: the index holds every offense with
|
|
288
|
+
the source line it was found on, which is 336 MB over `ruby/ruby`. A second run against a warm cache
|
|
289
|
+
answers in 1.59 s there, and in 0.42 s over Rails.
|
|
290
|
+
|
|
279
291
|
Machine: Apple M2 (8 cores), Ruby 4.0.6 with YJIT available, RubyGems-installed RuboCop 1.89.0.
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
292
|
+
Measured on 2026-08-31 against the corpora at `rubocop_rubocop` 2693129, `mastodon_mastodon` b59ddc7,
|
|
293
|
+
`Homebrew_brew` b42173b, `rails_rails` a19f07f and `ruby_ruby` 22e4a75. The one-minute load average
|
|
294
|
+
was between 4.5 and 7.1 as each row was taken — most of it RuboCop's own parallel workers, which is
|
|
295
|
+
inherent to measuring them. **The machine was in use, not idle.** Both tools ran back to back under
|
|
296
|
+
the same conditions on each corpus, so the ratios hold, but the absolute seconds are not a floor:
|
|
297
|
+
expect better on a quiet machine. Anything competing for cores inflates both sides, and not by the
|
|
298
|
+
same factor on each, which is what makes the parallel column move as much as it does. If the
|
|
299
|
+
absolute numbers matter to you, measure on an idle machine and record the load either side of the
|
|
300
|
+
run — a figure without that context cannot be compared with another one.
|
|
289
301
|
|
|
290
302
|
## Development
|
|
291
303
|
|
data/lib/sonicop/version.rb
CHANGED
data/src/config/inheritance.rs
CHANGED
|
@@ -8,6 +8,8 @@ use std::time::Duration;
|
|
|
8
8
|
use anyhow::{Context, Result, bail};
|
|
9
9
|
use serde_yaml_ng::{Mapping, Value};
|
|
10
10
|
|
|
11
|
+
const MAX_REMOTE_CONFIG_BYTES: u64 = 5 * 1024 * 1024;
|
|
12
|
+
|
|
11
13
|
/// Configuration files whose inheritance has already been resolved, keyed by canonical path for
|
|
12
14
|
/// local files and by URL for remote ones.
|
|
13
15
|
///
|
|
@@ -164,7 +166,8 @@ fn fetch_remote_config(url: &str) -> Result<String> {
|
|
|
164
166
|
response
|
|
165
167
|
.body_mut()
|
|
166
168
|
.with_config()
|
|
167
|
-
|
|
169
|
+
// ureq は指定値と同じ長さでも上限超過にするため、論理上限を含む 1 バイト先を渡す。
|
|
170
|
+
.limit(MAX_REMOTE_CONFIG_BYTES + 1)
|
|
168
171
|
.read_to_string()
|
|
169
172
|
.with_context(|| format!("failed to read remote configuration: {url}"))
|
|
170
173
|
}
|
|
@@ -459,14 +462,17 @@ fn mode_keys(mode: &Value, name: &str) -> HashSet<String> {
|
|
|
459
462
|
mod tests {
|
|
460
463
|
use std::collections::HashSet;
|
|
461
464
|
use std::fs;
|
|
465
|
+
use std::io::{Read, Write};
|
|
466
|
+
use std::net::TcpListener;
|
|
462
467
|
use std::path::Path;
|
|
468
|
+
use std::thread;
|
|
463
469
|
|
|
464
470
|
use serde_yaml_ng::Value;
|
|
465
471
|
use tempfile::tempdir;
|
|
466
472
|
|
|
467
473
|
use super::{
|
|
468
|
-
InheritMode, PARSED_CONFIG_COUNT, deep_merge,
|
|
469
|
-
merge_config, merge_inherited_config,
|
|
474
|
+
InheritMode, MAX_REMOTE_CONFIG_BYTES, PARSED_CONFIG_COUNT, deep_merge, fetch_remote_config,
|
|
475
|
+
join_remote_url, load_with_inheritance, merge_config, merge_inherited_config,
|
|
470
476
|
};
|
|
471
477
|
use crate::config::Config;
|
|
472
478
|
|
|
@@ -483,6 +489,24 @@ mod tests {
|
|
|
483
489
|
load_with_inheritance(path, &mut HashSet::new())
|
|
484
490
|
}
|
|
485
491
|
|
|
492
|
+
fn serve_once(body: Vec<u8>) -> (String, thread::JoinHandle<()>) {
|
|
493
|
+
let listener = TcpListener::bind(("127.0.0.1", 0)).unwrap();
|
|
494
|
+
let address = listener.local_addr().unwrap();
|
|
495
|
+
let server = thread::spawn(move || {
|
|
496
|
+
let (mut stream, _) = listener.accept().unwrap();
|
|
497
|
+
let mut request = [0; 1024];
|
|
498
|
+
assert_ne!(stream.read(&mut request).unwrap(), 0);
|
|
499
|
+
write!(
|
|
500
|
+
stream,
|
|
501
|
+
"HTTP/1.1 200 OK\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
|
|
502
|
+
body.len()
|
|
503
|
+
)
|
|
504
|
+
.unwrap();
|
|
505
|
+
stream.write_all(&body).unwrap();
|
|
506
|
+
});
|
|
507
|
+
(format!("http://{address}/config.yml"), server)
|
|
508
|
+
}
|
|
509
|
+
|
|
486
510
|
fn cop_exclude(merged: &Value, cop: &str) -> Value {
|
|
487
511
|
merged
|
|
488
512
|
.as_mapping()
|
|
@@ -577,6 +601,24 @@ mod tests {
|
|
|
577
601
|
assert!(join_remote_url("no-directory", "shared.yml").is_err());
|
|
578
602
|
}
|
|
579
603
|
|
|
604
|
+
#[test]
|
|
605
|
+
fn remote_configuration_enforces_the_response_size_limit() {
|
|
606
|
+
let limit = MAX_REMOTE_CONFIG_BYTES as usize;
|
|
607
|
+
|
|
608
|
+
let (url, server) = serve_once(vec![b'a'; limit]);
|
|
609
|
+
let accepted = fetch_remote_config(&url).unwrap();
|
|
610
|
+
server.join().unwrap();
|
|
611
|
+
assert_eq!(accepted.len(), limit);
|
|
612
|
+
|
|
613
|
+
let (url, server) = serve_once(vec![b'a'; limit + 1]);
|
|
614
|
+
let error = fetch_remote_config(&url).unwrap_err().to_string();
|
|
615
|
+
server.join().unwrap();
|
|
616
|
+
assert!(
|
|
617
|
+
error.starts_with("failed to read remote configuration:"),
|
|
618
|
+
"unexpected error: {error}"
|
|
619
|
+
);
|
|
620
|
+
}
|
|
621
|
+
|
|
580
622
|
#[test]
|
|
581
623
|
fn merges_configurations_without_losing_untouched_keys() {
|
|
582
624
|
let merged = merge_config(
|
data/src/engine.rs
CHANGED
|
@@ -10,7 +10,6 @@ use ignore::WalkBuilder;
|
|
|
10
10
|
use rayon::prelude::*;
|
|
11
11
|
use serde::{Deserialize, Serialize};
|
|
12
12
|
use tempfile::NamedTempFile;
|
|
13
|
-
use tree_sitter::Parser;
|
|
14
13
|
|
|
15
14
|
use crate::config::{Config, ConfigStore};
|
|
16
15
|
use crate::cop_name::selector_matches;
|
|
@@ -554,7 +553,16 @@ fn persist_cache_index(path: &Path, index: &CacheIndex) -> bool {
|
|
|
554
553
|
let Ok(mut temporary) = NamedTempFile::new_in(parent) else {
|
|
555
554
|
return false;
|
|
556
555
|
};
|
|
557
|
-
|
|
556
|
+
// **Buffered.** `serde_json::to_writer` hands the writer each token as it produces it, so an
|
|
557
|
+
// unbuffered `File` turns one index into millions of `write` calls. The index holds every
|
|
558
|
+
// offense of every file with the source line it was found on, which is 336 MB over `ruby/ruby`:
|
|
559
|
+
// writing it a token at a time cost 115 seconds of a 135-second run, nearly all of it blocked
|
|
560
|
+
// in the kernel rather than serializing.
|
|
561
|
+
let written = {
|
|
562
|
+
let mut writer = std::io::BufWriter::with_capacity(1 << 20, temporary.as_file_mut());
|
|
563
|
+
serde_json::to_writer(&mut writer, index).is_ok() && writer.flush().is_ok()
|
|
564
|
+
};
|
|
565
|
+
if !written
|
|
558
566
|
|| temporary.as_file_mut().flush().is_err()
|
|
559
567
|
|| temporary.as_file().sync_all().is_err()
|
|
560
568
|
{
|
|
@@ -992,12 +1000,8 @@ fn inspect_planned(
|
|
|
992
1000
|
let length_as_read = text.len();
|
|
993
1001
|
let text = crate::nul_bytes::as_ruby_reads_it(&text).unwrap_or(text);
|
|
994
1002
|
let source = SourceFile::new(path, text).read_as_long_as(length_as_read);
|
|
995
|
-
let mut parser = Parser::new();
|
|
996
|
-
parser
|
|
997
|
-
.set_language(&tree_sitter_ruby::LANGUAGE.into())
|
|
998
|
-
.context("failed to initialize the Ruby parser")?;
|
|
999
1003
|
let tree = crate::profile::phase(crate::profile::Phase::Parse, || {
|
|
1000
|
-
parser
|
|
1004
|
+
crate::parser::parse(source.text())
|
|
1001
1005
|
})
|
|
1002
1006
|
.context("Ruby parser returned no syntax tree")?;
|
|
1003
1007
|
let ast = crate::profile::phase(crate::profile::Phase::Index, || {
|
data/src/lib.rs
CHANGED
data/src/nul_bytes.rs
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
use std::ops::Range;
|
|
25
25
|
|
|
26
|
-
use tree_sitter::
|
|
26
|
+
use tree_sitter::Node;
|
|
27
27
|
|
|
28
28
|
/// The byte a NUL inside a comment is read as.
|
|
29
29
|
///
|
|
@@ -144,11 +144,7 @@ thread_local! {
|
|
|
144
144
|
fn parse(text: &str) -> Option<tree_sitter::Tree> {
|
|
145
145
|
#[cfg(test)]
|
|
146
146
|
PARSES.with(|parses| parses.set(parses.get() + 1));
|
|
147
|
-
|
|
148
|
-
parser
|
|
149
|
-
.set_language(&tree_sitter_ruby::LANGUAGE.into())
|
|
150
|
-
.ok()?;
|
|
151
|
-
parser.parse(text, None)
|
|
147
|
+
crate::parser::parse(text)
|
|
152
148
|
}
|
|
153
149
|
|
|
154
150
|
/// The nodes that hold the text of a literal. `%w` and `%i` wrap theirs in a `bare_string` or a
|
data/src/parser.rs
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//! One Ruby parser per worker thread.
|
|
2
|
+
//!
|
|
3
|
+
//! `Parser::new` allocates the parse stack, the lexer buffers and the reusable subtree pool, and
|
|
4
|
+
//! `set_language` resets all of them. That is work the file being read has nothing to do with, and
|
|
5
|
+
//! several places used to repeat it for every file, every recovered fragment and every syntax
|
|
6
|
+
//! probe. A sampling profile put it among the costs of a run.
|
|
7
|
+
//!
|
|
8
|
+
//! The tree a parse returns owns its own storage, so nothing here is shared with the caller.
|
|
9
|
+
|
|
10
|
+
use std::cell::RefCell;
|
|
11
|
+
|
|
12
|
+
use tree_sitter::{Parser, Tree};
|
|
13
|
+
|
|
14
|
+
thread_local! {
|
|
15
|
+
static PARSER: RefCell<Option<Parser>> = const { RefCell::new(None) };
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// Parses `text` with this thread's parser, building one on first use.
|
|
19
|
+
///
|
|
20
|
+
/// `None` means the parser produced no tree at all, which is not the same as a tree holding
|
|
21
|
+
/// errors: a source the grammar cannot read still comes back as a tree with `ERROR` nodes.
|
|
22
|
+
pub(crate) fn parse(text: &str) -> Option<Tree> {
|
|
23
|
+
PARSER.with(|slot| {
|
|
24
|
+
let mut slot = slot.borrow_mut();
|
|
25
|
+
let parser = match slot.as_mut() {
|
|
26
|
+
Some(parser) => parser,
|
|
27
|
+
None => {
|
|
28
|
+
let mut parser = Parser::new();
|
|
29
|
+
parser
|
|
30
|
+
.set_language(&tree_sitter_ruby::LANGUAGE.into())
|
|
31
|
+
.expect("the grammar the whole run is parsed with");
|
|
32
|
+
slot.insert(parser)
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
parser.parse(text, None)
|
|
36
|
+
})
|
|
37
|
+
}
|
data/src/profile.rs
CHANGED
|
@@ -101,10 +101,18 @@ pub(crate) enum Phase {
|
|
|
101
101
|
CacheKey,
|
|
102
102
|
/// Reading a cached report back and turning it into offenses.
|
|
103
103
|
CacheLoad,
|
|
104
|
+
/// `VariableForce`, built on the first cop of a file that asks for it.
|
|
105
|
+
Variables,
|
|
106
|
+
/// The code the grammar swallowed, recovered on the first cop that asks.
|
|
107
|
+
Fragments,
|
|
108
|
+
/// The Metrics cops' local-variable replay, built on the first cop that asks.
|
|
109
|
+
MetricLocals,
|
|
110
|
+
/// The lexer token stream, rebuilt on the first cop that asks.
|
|
111
|
+
LayoutTokens,
|
|
104
112
|
}
|
|
105
113
|
|
|
106
114
|
impl Phase {
|
|
107
|
-
const COUNT: usize =
|
|
115
|
+
const COUNT: usize = 17;
|
|
108
116
|
const NAMES: [&'static str; Self::COUNT] = [
|
|
109
117
|
"read",
|
|
110
118
|
"parse",
|
|
@@ -119,6 +127,10 @@ impl Phase {
|
|
|
119
127
|
"shebang",
|
|
120
128
|
"cache_key",
|
|
121
129
|
"cache_load",
|
|
130
|
+
"variables",
|
|
131
|
+
"fragments",
|
|
132
|
+
"metric_locals",
|
|
133
|
+
"layout_tokens",
|
|
122
134
|
];
|
|
123
135
|
}
|
|
124
136
|
|
|
@@ -2,10 +2,11 @@ use tree_sitter::Node;
|
|
|
2
2
|
|
|
3
3
|
use crate::diagnostic::Offense;
|
|
4
4
|
use crate::rules::RuleContext;
|
|
5
|
-
use crate::rules::send_node::{arguments, first_line_range,
|
|
5
|
+
use crate::rules::send_node::{arguments, first_line_range, send_range};
|
|
6
6
|
|
|
7
7
|
use super::support::declarations;
|
|
8
8
|
use crate::rules::node_ext::NodeExt;
|
|
9
|
+
use crate::rules::send_node::named_children_of;
|
|
9
10
|
|
|
10
11
|
/// `SOURCE_BLOCK_NAMES`. A group declared under a different source, git remote, platform or path is
|
|
11
12
|
/// a different group even when it goes by the same name.
|
|
@@ -71,7 +72,7 @@ fn attributes(node: Node<'_>, context: &RuleContext<'_>) -> String {
|
|
|
71
72
|
// `group :a, foo: 1` and `group :a, foo: 1` agree however they were spaced.
|
|
72
73
|
if parts.len() > 1 || parts[0].kind_str() == "hash" {
|
|
73
74
|
let mut pairs: Vec<String> = match parts[0].kind_str() == "hash" {
|
|
74
|
-
true =>
|
|
75
|
+
true => named_children_of(parts[0], context),
|
|
75
76
|
false => parts.to_vec(),
|
|
76
77
|
}
|
|
77
78
|
.into_iter()
|
|
@@ -7,10 +7,11 @@ use tree_sitter::Node;
|
|
|
7
7
|
use crate::diagnostic::Offense;
|
|
8
8
|
use crate::rules::RuleContext;
|
|
9
9
|
use crate::rules::node_ext::NodeExt;
|
|
10
|
-
use crate::rules::
|
|
10
|
+
use crate::rules::{push_named_children_in};
|
|
11
11
|
use crate::rules::send_node::{arguments, is_string, pair_key_symbol, send_range, string_text};
|
|
12
12
|
|
|
13
13
|
use super::support::gem_declarations;
|
|
14
|
+
use crate::rules::send_node::named_children_iter;
|
|
14
15
|
|
|
15
16
|
const MSG: &str = "Missing gem description comment.";
|
|
16
17
|
|
|
@@ -179,7 +180,7 @@ fn subtree_lines(node: Node<'_>, context: &RuleContext<'_>) -> HashSet<usize> {
|
|
|
179
180
|
continue;
|
|
180
181
|
}
|
|
181
182
|
lines.insert(context.source.line_column(current.start_byte()).0);
|
|
182
|
-
|
|
183
|
+
push_named_children_in(current, context, &mut stack);
|
|
183
184
|
}
|
|
184
185
|
lines
|
|
185
186
|
}
|
|
@@ -224,8 +225,8 @@ fn gem_options<'a>(node: Node<'_>, context: &'a RuleContext<'_>) -> Vec<&'a str>
|
|
|
224
225
|
};
|
|
225
226
|
let pairs: Vec<Node<'_>> = match last.first().kind_str() {
|
|
226
227
|
"hash" if last.parts().len() == 1 => {
|
|
227
|
-
let
|
|
228
|
-
last.first()
|
|
228
|
+
let _cursor = last.first().walk();
|
|
229
|
+
named_children_iter(last.first(), context).collect()
|
|
229
230
|
}
|
|
230
231
|
_ => last.parts().to_vec(),
|
|
231
232
|
};
|
|
@@ -3,9 +3,10 @@ use tree_sitter::Node;
|
|
|
3
3
|
use crate::diagnostic::Offense;
|
|
4
4
|
use crate::rules::RuleContext;
|
|
5
5
|
use crate::rules::node_ext::NodeExt;
|
|
6
|
-
use crate::rules::send_node::
|
|
6
|
+
use crate::rules::send_node::is_plain_send;
|
|
7
7
|
|
|
8
8
|
use super::support::{first_specification_variable, is_literal, is_specification_receiver};
|
|
9
|
+
use crate::rules::send_node::named_children_of;
|
|
9
10
|
|
|
10
11
|
pub(super) fn check(context: &RuleContext<'_>, offenses: &mut Vec<Offense>) {
|
|
11
12
|
let variable = first_specification_variable(context);
|
|
@@ -34,7 +35,7 @@ pub(super) fn check(context: &RuleContext<'_>, offenses: &mut Vec<Offense>) {
|
|
|
34
35
|
// multiple assignment carries no value of its own, so it never matches upstream's
|
|
35
36
|
// `(send _ :[]= literal? _)`, which insists on both an index and a value.
|
|
36
37
|
"left_assignment_list" => {
|
|
37
|
-
for target in
|
|
38
|
+
for target in named_children_of(left, context) {
|
|
38
39
|
if target.kind_str() == "call"
|
|
39
40
|
&& let Some(attribute) = assigned_attribute(target, variable, context)
|
|
40
41
|
{
|
|
@@ -93,7 +94,7 @@ fn indexed_attribute<'a>(
|
|
|
93
94
|
if !is_specification_receiver(receiver, variable, context) {
|
|
94
95
|
return None;
|
|
95
96
|
}
|
|
96
|
-
let indices =
|
|
97
|
+
let indices = named_children_of(target, context);
|
|
97
98
|
let [index] = indices.get(1..)? else {
|
|
98
99
|
return None;
|
|
99
100
|
};
|