Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

2371-3 #290

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

2371-3 #290

wants to merge 1 commit into from

Conversation

brutu33
Copy link
Contributor

@brutu33 brutu33 commented Jul 27, 2018

Номер

2371

Номер задания

3

Комментарии

Task 3: parsing comments from onliner link

class OnlinerApiHandler
def handle_data(data)
JSON(data)['comments'].each_with_index.map do |value, index|
{ id: index + 1, text: value['text'], author: value['author']['name'] }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FeatureEnvy: OnlinerApiHandler#handle_data refers to 'value' more than self (maybe move it to another class?). More info.

attribute :text
attribute :author
attribute :rating
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

@@ -0,0 +1,6 @@
require "ohm"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

attribute :link
attribute :rating
set :comments, :Comment
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

@@ -0,0 +1,6 @@
require "ohm"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

comment.id == score['id'].to_i
end.rating = score['score']
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EmptyLinesAroundMethodBody: Extra empty line detected at method body end.


def add_comments_score(scores)
scores.each do |score|
comments.detect do |comment|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NestedIterators: ArticleHelper#add_comments_score contains iterators nested 2 deep. More info.

def add_comments_score(scores)
scores.each do |score|
comments.detect do |comment|
comment.id == score['id'].to_i

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FeatureEnvy: ArticleHelper#add_comments_score refers to 'score' more than self (maybe move it to another class?). More info.

@@ -0,0 +1,30 @@
require_relative 'helper'
class ArticleHelper < Helper
attr_accessor :id, :link, :comments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attribute: ArticleHelper#comments is a writable attribute. More info.
Attribute: ArticleHelper#id is a writable attribute. More info.
Attribute: ArticleHelper#link is a writable attribute. More info.

end
end

# puts ApplicationHelper.new("https://tech.onliner.by/2018/07/24/magic").search_article_comments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

class OnlinerApiHandler
def handle_data(data)
JSON(data)['comments'].each_with_index.map do |value, index|
{ id: index + 1, text: value['text'], author: value['author']['name'] }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FeatureEnvy: OnlinerApiHandler#handle_data refers to 'value' more than self (maybe move it to another class?). More info.

attribute :text
attribute :author
attribute :rating
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

@@ -0,0 +1,6 @@
require "ohm"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

attribute :link
attribute :rating
set :comments, :Comment
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

@@ -0,0 +1,6 @@
require "ohm"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style/StringLiterals: Prefer single-quoted strings when you don't need string interpolation or special symbols.

comment.id == score['id'].to_i
end.rating = score['score']
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/EmptyLinesAroundMethodBody: Extra empty line detected at method body end.


def add_comments_score(scores)
scores.each do |score|
comments.detect do |comment|

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NestedIterators: ArticleHelper#add_comments_score contains iterators nested 2 deep. More info.

def add_comments_score(scores)
scores.each do |score|
comments.detect do |comment|
comment.id == score['id'].to_i

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FeatureEnvy: ArticleHelper#add_comments_score refers to 'score' more than self (maybe move it to another class?). More info.

@@ -0,0 +1,30 @@
require_relative 'helper'
class ArticleHelper < Helper
attr_accessor :id, :link, :comments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attribute: ArticleHelper#comments is a writable attribute. More info.
Attribute: ArticleHelper#id is a writable attribute. More info.
Attribute: ArticleHelper#link is a writable attribute. More info.

end
end

# puts ApplicationHelper.new("https://tech.onliner.by/2018/07/24/magic").search_article_comments

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout/TrailingBlankLines: Final newline missing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants