mayoral/telegrammer

View on GitHub

Showing 16 of 16 total issues

Method api_request has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
Open

    def api_request(action, params, params_validation)
      api_uri = "bot#{@api_token}/#{action}"

      if params_validation.nil?
        validated_params = params
Severity: Minor
Found in lib/telegrammer/bot.rb - About 2 hrs 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 api_request has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def api_request(action, params, params_validation)
      api_uri = "bot#{@api_token}/#{action}"

      if params_validation.nil?
        validated_params = params
Severity: Minor
Found in lib/telegrammer/bot.rb - About 1 hr to fix

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

      module DataTypes
        # Telegram InlineQueryResultVenue data type
        #
        # @attr [String] type Type of the result, must be article
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_document.rb on lines 2..31

    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 44.

    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

      module DataTypes
        # Telegram InlineQueryResultDocument data type
        #
        # @attr [String] type Type of the result, must be document
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_venue.rb on lines 2..31

    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 44.

    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

      module DataTypes
        # Telegram InlineQueryResultPhoto data type
        #
        # @attr [String] type Type of the result, must be photo
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_article.rb on lines 2..29

    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 41.

    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

      module DataTypes
        # Telegram InlineQueryResultArticle data type
        #
        # @attr [String] type Type of the result, must be article
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_photo.rb on lines 2..29

    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 41.

    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

    Method get_updates has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
    Open

        def get_updates(opts={}, &_block)
          loop do
            if opts[:fail_silently]
              @fail_silently = true
            end
    Severity: Minor
    Found in lib/telegrammer/bot.rb - About 45 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 3 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultLocation data type
        #
        # @attr [String] type Type of the result, must be location
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_contact.rb on lines 2..27
    lib/telegrammer/data_types/inline_query_result/inline_query_result_mpeg4_gif.rb on lines 2..27

    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 38.

    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 3 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultMpeg4Gif data type
        #
        # @attr [String] type Type of the result, must be mpeg4_gif
        # @attr [String] id Unique identifier for this result, 1-64 bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_contact.rb on lines 2..27
    lib/telegrammer/data_types/inline_query_result/inline_query_result_location.rb on lines 2..27

    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 38.

    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 3 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultContact data type
        #
        # @attr [String] type Type of the result, must be contact
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_location.rb on lines 2..27
    lib/telegrammer/data_types/inline_query_result/inline_query_result_mpeg4_gif.rb on lines 2..27

    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 38.

    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 6 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultAudio data type
        #
        # @attr [String] type Type of the result, must be audio
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_document.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_mpeg4_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_photo.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_video.rb on lines 2..23

    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 32.

    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 6 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultCachedDocument data type
        #
        # @attr [String] type Type of the result, must be document
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_audio.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_mpeg4_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_photo.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_video.rb on lines 2..23

    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 32.

    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 6 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultCachedMpeg4Gif data type
        #
        # @attr [String] type Type of the result, must be mpeg4_gif
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_audio.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_document.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_photo.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_video.rb on lines 2..23

    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 32.

    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 6 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultCachedPhoto data type
        #
        # @attr [String] type Type of the result, must be photo
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_audio.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_document.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_mpeg4_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_video.rb on lines 2..23

    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 32.

    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 6 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultCachedVideo data type
        #
        # @attr [String] type Type of the result, must be video
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_audio.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_document.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_mpeg4_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_photo.rb on lines 2..23

    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 32.

    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 6 locations. Consider refactoring.
    Open

      module DataTypes
        # Telegram InlineQueryResultCachedGif data type
        #
        # @attr [String] type Type of the result, must be gif
        # @attr [String] id Unique identifier for this result, 1-64 Bytes
    lib/telegrammer/data_types/inline_query_result/inline_query_result_audio.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_document.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_mpeg4_gif.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_photo.rb on lines 2..23
    lib/telegrammer/data_types/inline_query_result/inline_query_result_cached_video.rb on lines 2..23

    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 32.

    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