From d1a3936556a4a63c31ab9e679b5d4092fccbffc3 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 19 Feb 2024 22:27:00 -0500 Subject: [PATCH] Allow (x || raise) in rubocop --- .rubocop.yml | 5 +++++ lib/rambling/trie/configuration/provider_collection.rb | 1 + lib/rambling/trie/container.rb | 8 +++++--- lib/rambling/trie/serializers/zip.rb | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index a9c76430..0fb4c434 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1327,6 +1327,8 @@ Metrics/AbcSize: # The ABC size is a calculated magnitude, so this number can be an Integer or # a Float. Max: 20 + AllowedMethods: + - 'closest_node' Exclude: - 'tasks/*.rb' @@ -1353,6 +1355,9 @@ Metrics/ClassLength: # Avoid complex methods. Metrics/CyclomaticComplexity: Max: 6 + AllowedMethods: + - 'children_match_prefix' + - 'closest_node' Metrics/MethodLength: CountComments: false # count full line comments? diff --git a/lib/rambling/trie/configuration/provider_collection.rb b/lib/rambling/trie/configuration/provider_collection.rb index 059467e4..df270df0 100644 --- a/lib/rambling/trie/configuration/provider_collection.rb +++ b/lib/rambling/trie/configuration/provider_collection.rb @@ -105,6 +105,7 @@ def file_format filepath def contains? provider return true if provider.nil? + p = (provider || raise) providers.any? && provider_instances.include?(p) end diff --git a/lib/rambling/trie/container.rb b/lib/rambling/trie/container.rb index c9b160df..b1dda0c3 100644 --- a/lib/rambling/trie/container.rb +++ b/lib/rambling/trie/container.rb @@ -201,16 +201,18 @@ def words_within_root phrase return enum_for :words_within_root, phrase unless block_given? chars = phrase.chars + # rubocop:disable Style/CommentedKeyword 0.upto(chars.length - 1).each do |starting_index| - new_phrase = chars.slice starting_index..(chars.length - 1) #: Array[String] + new_phrase = chars.slice starting_index..(chars.length - 1) # : Array[String] root.match_prefix new_phrase do |word| yield word end - end #: Enumerator[String, void] + end # : Enumerator[String, void] + # rubocop:enable Style/CommentedKeyword end def compress_root - compressor.compress root #: Nodes::Compressed + compressor.compress root # : Nodes::Compressed end def char_symbols word diff --git a/lib/rambling/trie/serializers/zip.rb b/lib/rambling/trie/serializers/zip.rb index 740b63b9..b90ffb97 100644 --- a/lib/rambling/trie/serializers/zip.rb +++ b/lib/rambling/trie/serializers/zip.rb @@ -54,6 +54,7 @@ def dump contents, filepath serializer = serializers.resolve filename raise if serializer.nil? + serializer.dump contents, entry_path zip.add filename, entry_path