ignacio-chiazzo/ruby_whatsapp_sdk

View on GitHub

Showing 10 of 29 total issues

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

require_relative "request"
require_relative "response"

module WhatsappSdk
  module Api
Severity: Minor
Found in lib/whatsapp_sdk/api/messages.rb - About 5 hrs to fix

    File example.rb has 272 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 2 hrs to fix

      Method send_template has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

            def send_template(
              sender_id:, recipient_number:, name:, language:, components: nil, components_json: nil
            )
              if !components && !components_json
                raise Resource::Errors::MissingArgumentError,
      Severity: Minor
      Found in lib/whatsapp_sdk/api/messages.rb - About 1 hr to fix

        Method send_document has 26 lines of code (exceeds 25 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 1 hr to fix

          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.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 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 validate_attributes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

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