rubysg/rubysg-reboot

View on GitHub

Showing 13 of 13 total issues

Method perform has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def perform(id)
    sub = RubySgBotSubscriber.find_by!(chat_id: id.to_s)
    featured_articles = RubyWeekly.new.featured_articles

    send_telegram_message(
Severity: Minor
Found in app/jobs/send_weekly_updates_job.rb - About 1 hr to fix

    Method questions has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

        def questions(qns = [])
          qns.each do |qn|
            raise(WrongQuestionFormatError, "Question must contain key") unless qn.include?(:key)
            raise(WrongQuestionFormatError, "Question must contain question") unless qn.include?(:question)
    
    
    Severity: Minor
    Found in app/forms/feedback_form.rb - About 55 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Method featured_articles has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

      def featured_articles
        doc = Nokogiri::HTML(latest_feed["description"])
        contents = doc.search('/html/body/table/tr/td/div/table')
    
        jobs_section_index = 0
    Severity: Minor
    Found in app/services/ruby_weekly.rb - About 35 mins to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      def ruby_sg_bot_left_group?
        (tg_object[:chat][:type] == "group" || tg_object[:chat][:type] == "supergroup") &&
          tg_object[:left_chat_member] &&
          tg_object[:left_chat_member][:id].to_s == rubysg_bot_id
      end
    Severity: Minor
    Found in app/controllers/api/ruby_sg_bot_controller.rb and 1 other location - About 25 mins to fix
    app/controllers/api/ruby_sg_bot_controller.rb on lines 32..36

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 2 locations. Consider refactoring.
    Open

      def ruby_sg_bot_joined_group?
        (tg_object[:chat][:type] == "group" || tg_object[:chat][:type] == "supergroup") &&
          tg_object[:new_chat_member] &&
          tg_object[:new_chat_member][:id].to_s == rubysg_bot_id
      end
    Severity: Minor
    Found in app/controllers/api/ruby_sg_bot_controller.rb and 1 other location - About 25 mins to fix
    app/controllers/api/ruby_sg_bot_controller.rb on lines 38..42

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 30.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class BehindTheGems5 < FeedbackForm
        title "Behind the Gems 5 :: 6"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/behind_the_gems5.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems2.rb on lines 4..18
    app/forms/feedback/behind_the_gems3.rb on lines 4..18
    app/forms/feedback/behind_the_gems4.rb on lines 4..18
    app/forms/feedback/meetup03082022.rb on lines 4..18
    app/forms/feedback/meetup04102022.rb on lines 2..16
    app/forms/feedback/meetup07092022.rb on lines 2..16
    app/forms/feedback/meetup10052023.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class BehindTheGems3 < FeedbackForm
        title "Behind the Gems 3 :: 6"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/behind_the_gems3.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems2.rb on lines 4..18
    app/forms/feedback/behind_the_gems4.rb on lines 4..18
    app/forms/feedback/behind_the_gems5.rb on lines 4..18
    app/forms/feedback/meetup03082022.rb on lines 4..18
    app/forms/feedback/meetup04102022.rb on lines 2..16
    app/forms/feedback/meetup07092022.rb on lines 2..16
    app/forms/feedback/meetup10052023.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class Meetup03082022 < FeedbackForm
        title "August 2022 Meetup"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/meetup03082022.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems2.rb on lines 4..18
    app/forms/feedback/behind_the_gems3.rb on lines 4..18
    app/forms/feedback/behind_the_gems4.rb on lines 4..18
    app/forms/feedback/behind_the_gems5.rb on lines 4..18
    app/forms/feedback/meetup04102022.rb on lines 2..16
    app/forms/feedback/meetup07092022.rb on lines 2..16
    app/forms/feedback/meetup10052023.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class Meetup04102022 < FeedbackForm
        title "October 2022 Meetup"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/meetup04102022.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems2.rb on lines 4..18
    app/forms/feedback/behind_the_gems3.rb on lines 4..18
    app/forms/feedback/behind_the_gems4.rb on lines 4..18
    app/forms/feedback/behind_the_gems5.rb on lines 4..18
    app/forms/feedback/meetup03082022.rb on lines 4..18
    app/forms/feedback/meetup07092022.rb on lines 2..16
    app/forms/feedback/meetup10052023.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class Meetup07092022 < FeedbackForm
        title "September 2022 Meetup"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/meetup07092022.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems2.rb on lines 4..18
    app/forms/feedback/behind_the_gems3.rb on lines 4..18
    app/forms/feedback/behind_the_gems4.rb on lines 4..18
    app/forms/feedback/behind_the_gems5.rb on lines 4..18
    app/forms/feedback/meetup03082022.rb on lines 4..18
    app/forms/feedback/meetup04102022.rb on lines 2..16
    app/forms/feedback/meetup10052023.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class Meetup10052023 < FeedbackForm
        title "May 2023 Meetup"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/meetup10052023.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems2.rb on lines 4..18
    app/forms/feedback/behind_the_gems3.rb on lines 4..18
    app/forms/feedback/behind_the_gems4.rb on lines 4..18
    app/forms/feedback/behind_the_gems5.rb on lines 4..18
    app/forms/feedback/meetup03082022.rb on lines 4..18
    app/forms/feedback/meetup04102022.rb on lines 2..16
    app/forms/feedback/meetup07092022.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class BehindTheGems4 < FeedbackForm
        title "Behind the Gems 4 :: 6"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/behind_the_gems4.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems2.rb on lines 4..18
    app/forms/feedback/behind_the_gems3.rb on lines 4..18
    app/forms/feedback/behind_the_gems5.rb on lines 4..18
    app/forms/feedback/meetup03082022.rb on lines 4..18
    app/forms/feedback/meetup04102022.rb on lines 2..16
    app/forms/feedback/meetup07092022.rb on lines 2..16
    app/forms/feedback/meetup10052023.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Similar blocks of code found in 8 locations. Consider refactoring.
    Open

      class BehindTheGems2 < FeedbackForm
        title "Behind the Gems 2 :: 6"
    
        questions [
          {
    Severity: Major
    Found in app/forms/feedback/behind_the_gems2.rb and 7 other locations - About 15 mins to fix
    app/forms/feedback/behind_the_gems3.rb on lines 4..18
    app/forms/feedback/behind_the_gems4.rb on lines 4..18
    app/forms/feedback/behind_the_gems5.rb on lines 4..18
    app/forms/feedback/meetup03082022.rb on lines 4..18
    app/forms/feedback/meetup04102022.rb on lines 2..16
    app/forms/feedback/meetup07092022.rb on lines 2..16
    app/forms/feedback/meetup10052023.rb on lines 2..16

    Duplicated Code

    Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

    Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

    When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

    Tuning

    This issue has a mass of 25.

    We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

    The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

    If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

    See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

    Refactorings

    Further Reading

    Severity
    Category
    Status
    Source
    Language