ignacio-chiazzo/ruby_whatsapp_sdk

View on GitHub

Showing 8 of 24 total issues

File example.rb has 324 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'bundler/inline'

gemfile(true) do
  source 'https://rubygems.org'

Severity: Minor
Found in example.rb - About 3 hrs to fix

    File messages.rb has 265 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require_relative "request"
    
    module WhatsappSdk
      module Api
        class Messages < Request
    Severity: Minor
    Found in lib/whatsapp_sdk/api/messages.rb - About 2 hrs to fix

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

            def faraday(url:, multipart: false)
              ::Faraday.new(url) do |client|
                client.request(:multipart) if multipart
                client.request(:url_encoded)
                client.adapter(::Faraday.default_adapter)
      Severity: Minor
      Found in lib/whatsapp_sdk/api/client.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

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

            def to_json
              json = {}
              json[:id] = id unless id.nil?
              json[:link] = link unless link.nil?
              json[:caption] = caption unless caption.nil?
      Severity: Minor
      Found in lib/whatsapp_sdk/resource/media_component.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

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

            def validate_attributes
              [
                [Type::TEXT, text],
                [Type::IMAGE, image],
                [Type::DOCUMENT, document],
      Severity: Minor
      Found in lib/whatsapp_sdk/resource/interactive_header.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

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

            def validate_attributes
              [
                [Type::TEXT, text],
                [Type::CURRENCY, currency],
                [Type::DATE_TIME, date_time],
      Severity: Minor
      Found in lib/whatsapp_sdk/resource/parameter_object.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

      Method validate_list_message has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def validate_list_message
              button_length = button.length
              sections_count = sections.length
              unless button_length.positive?
                raise Errors::InvalidInteractiveActionButton,
      Severity: Minor
      Found in lib/whatsapp_sdk/resource/interactive_action.rb - About 25 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 send_document has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

            def send_document(
              sender_id:, recipient_number:, document_id: nil, link: nil, caption: "", message_id: nil, filename: nil
            )
              if !document_id && !link
                raise Resource::Errors::MissingArgumentError,
      Severity: Minor
      Found in lib/whatsapp_sdk/api/messages.rb - About 25 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

      Severity
      Category
      Status
      Source
      Language