Skip to content

Commit

Permalink
Update Reek configuration (#529)
Browse files Browse the repository at this point in the history
* Process Reek exceptions list

* Update Reek configuration
  • Loading branch information
dreikanter authored Aug 22, 2023
1 parent 210f04f commit 1498066
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 90 deletions.
25 changes: 0 additions & 25 deletions .reek-defaults.yml

This file was deleted.

65 changes: 7 additions & 58 deletions .reek.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
# Auto generated by Reeks --todo flag
# NOTE: Make sure custom Reek configuration is saved before calling reek --todo
---
exclude_paths:
- bin
- db
- node_modules
- public
- vendor
- db
- test
- spec
- vendor
detectors:
FeatureEnvy:
enabled: false
IrresponsibleModule:
enabled: false
TooManyConstants:
enabled: false
UncommunicativeModuleName:
enabled: false
UncommunicativeVariableName:
Expand All @@ -19,57 +22,3 @@ detectors:
- "_"
UtilityFunction:
public_methods_only: true
TooManyConstants:
enabled: false
ControlParameter:
exclude:
- Html#self.image_urls
- Html#self.link_urls
DuplicateMethodCall:
exclude:
- TheAtlanticPhotosNormalizer#direct_link
- FreefeedClientBuilder#call
- Html#self.paragraphs
- Html#self.post_excerpt
- ErrorDumperTest#test_backtrace
FeatureEnvy:
exclude:
- FormattingHelper#format_feed_state
- BaseNormalizer#sanitized_attachments
- ExplosmComicsNormalizer#normalized_image_uri
- GithubBlogNormalizer#safe_image_url
- MediumNormalizer#excerpt
- FeedsConfiguration#create_ot_update_existing_feeds
- NitterPermalink#call
- Push#freefeed_permalink
- CreateFeeds#change
- CreatePosts#change
- CreateDataPoints#change
- CreateErrors#change
- CreateNitterInstances#change
- KimchicuddlesNormalizerTest#expected
- RedakciyaNormalizerTest#expected
- SchneierNormalizerTest#expected
ManualDispatch:
exclude:
- RssNormalizer#published_at
- BaseProcessorTest#test_descendants_callable
TooManyStatements:
exclude:
- initialize
- FeedsTableHelper#feeds_table_header
- GithubBlogNormalizer#safe_image_url
- MediumNormalizer#excerpt
- DnsRecordsFetcher#self.call
- Html#self.paragraphs
- ProcessFeed#generate_new_posts
- ProcessFeed#push
- Push#publish_post_content
- TumblrImageFetcher#self.call
- CreatePosts#change
- CreateDelayedJobs#self.up
- CreateErrors#change
- CreateNitterInstances#change
- BaseLoaderTest#test_success
- BaseNormalizerTest#test_sanitize_attachments
- PostsPerWeekTest#test_calculates_posts_per_week
1 change: 1 addition & 0 deletions app/helpers/feeds_table_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module FeedsTableHelper
# :reek:TooManyStatements
def feeds_table_header(order_by:, order:)
tag.thead do
tag.tr do
Expand Down
1 change: 1 addition & 0 deletions app/models/normalized_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ class NormalizedEntity
attr_reader :feed_id, :uid, :link, :published_at, :text, :attachments, :comments, :validation_errors

# :reek:LongParameterList
# :reek:TooManyStatements
def initialize(
feed_id: nil,
uid: nil,
Expand Down
1 change: 1 addition & 0 deletions app/normalizers/github_blog_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def content_excerpt
DEFAULT_HOST = "blog.github.com".freeze
DEFAULT_SCHEME = "https".freeze

# :reek:TooManyStatements
def safe_image_url
value = Html.first_image_url(safe_content)
return unless value
Expand Down
1 change: 0 additions & 1 deletion app/normalizers/litterbox_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def bonus_panel_image_url
nil
end

# :reek:FeatureEnvy
def bonus_panel_page_url
Addressable::URI.parse(link).tap do |uri|
uri.path = uri.path.gsub(%r{/$}, "").gsub(/$/, "-bonus/")
Expand Down
1 change: 1 addition & 0 deletions app/normalizers/medium_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def description
Nokogiri::HTML(content.description)
end

# :reek:TooManyStatements
def excerpt
result = page_body
result.css("br").each { |element| element.replace "\n" }
Expand Down
1 change: 1 addition & 0 deletions app/normalizers/rss_normalizer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
class RssNormalizer < BaseNormalizer
delegate :link, to: :content

# :reek:ManualDispatch
def published_at
content.respond_to?(:pubDate) ? content.send(:pubDate) : content.dc_date
end
Expand Down
7 changes: 5 additions & 2 deletions app/normalizers/the_atlantic_photos_normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ def text
[description, direct_link].compact_blank.join(separator)
end

# :reek:FeatureEnvy
def direct_link
RestClient.get(content.link) do |response, _request, _result|
link = content.link

RestClient.get(link) do |response, _request, _result|
redirecting = [301, 302, 307].include?(response.code)
redirecting ? response.headers[:location] : content.link
redirecting ? response.headers[:location] : link
end
end

Expand Down
3 changes: 2 additions & 1 deletion app/services/process_feed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def process

private

# :reek:TooManyStatements
def generate_new_posts
feed.touch(:refreshed_at)
normalized_entities.reverse_each { |normalized_entity| push(normalized_entity) }
Expand All @@ -24,7 +25,7 @@ def generate_new_posts
dump_feed_error(e)
end

# :reek:FeatureEnvy
# :reek:TooManyStatements
def push(normalized_entity)
return unless normalized_entity
log_info("---> creating post; uid: [#{normalized_entity.uid}]")
Expand Down
2 changes: 2 additions & 0 deletions app/services/push.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# TODO: Drop this class
# :reek:TooManyStatements
class Push
include Logging
include Callee
Expand Down
1 change: 0 additions & 1 deletion app/services/service_instances_pool_updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def instance_urls
@instance_urls ||= instances_fetcher.new.call
end

# :reek:FeatureEnvy
def instances_stats
scope.select("state, COUNT(*) AS cnt").group(:state).map { "#{_1.state}: #{_1.cnt}" }.join("; ")
end
Expand Down
6 changes: 4 additions & 2 deletions app/support/html.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# frozen_string_literal: true

# TODO: Refactor this
# :reek:DuplicateMethodCall
# :reek:ControlParameter
class Html
MAX_POST_LENGTH = 1500
MAX_COMMENT_LENGTH = 1500
Expand Down Expand Up @@ -74,6 +75,7 @@ def self.link_urls(html, selector: nil)
end

# rubocop:disable Metrics/AbcSize
# :reek:TooManyStatements
def self.paragraphs(html)
result = Nokogiri::HTML(html)

Expand Down

0 comments on commit 1498066

Please sign in to comment.