ChattyCrow/chattycrow_ruby

View on GitHub

Showing 13 of 15 total issues

Method add_file has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

      def add_file(options = {})
        # Get file
        file = options.delete(:file)

        # Raise argument error when argument file missing!
Severity: Minor
Found in lib/chatty_crow/request/mail.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 proceed has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

    def proceed(raise_errors = true)
      # Empty requests?
      if requests.empty?
        if raise_errors
          fail ::ArgumentError, 'At least one message is required!'
Severity: Minor
Found in lib/chatty_crow/batch_notification_request.rb - About 1 hr 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 initialize has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def initialize(*args)
        # Error when attributes not exists!
        fail ::ArgumentError if args.empty?

        # Parse options and arguments
Severity: Minor
Found in lib/chatty_crow/request.rb - About 1 hr 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 proceed has 33 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    def proceed(raise_errors = true)
      # Empty requests?
      if requests.empty?
        if raise_errors
          fail ::ArgumentError, 'At least one message is required!'
Severity: Minor
Found in lib/chatty_crow/batch_notification_request.rb - About 1 hr to fix

    Method set_data_from_am has 29 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def set_data_from_am
            # Contacts
            @contacts  = ChattyCrow.wrap(@am_mail.to)
    
            # Channel?
    Severity: Minor
    Found in lib/chatty_crow/request/mail.rb - About 1 hr to fix

      Method set_data_from_am has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

            def set_data_from_am
              # Contacts
              @contacts  = ChattyCrow.wrap(@am_mail.to)
      
              # Channel?
      Severity: Minor
      Found in lib/chatty_crow/request/mail.rb - About 1 hr 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 execute has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def self.execute(instance, raise_errors = true)
            # Get options
            options = instance.to_json.merge(url: notification_url, method: :post)
      
            # Set options to JSON string
      Severity: Minor
      Found in lib/chatty_crow/notification_request.rb - About 1 hr to fix

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

            def host=(s)
              @host             = s
              @notification_url = s + (s[-1] == '/' ? '' : '/') + 'notification'
              @contacts_url     = s + (s[-1] == '/' ? '' : '/') + 'contacts'
              @messages_url     = s + (s[-1] == '/' ? '' : '/') + 'message'
        Severity: Minor
        Found in lib/chatty_crow/config.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 refresh_data has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def refresh_data(raise_errors = false)
              # Send request
              RestClient::Request.execute(call_options) do |response, request, result, &block|
                begin
                  case response.code
        Severity: Minor
        Found in lib/chatty_crow/message.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 execute has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
        Open

            def self.execute(instance, raise_errors = true)
              # Get options
              options = instance.to_json.merge(url: notification_url, method: :post)
        
              # Set options to JSON string
        Severity: Minor
        Found in lib/chatty_crow/notification_request.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 initialize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

              def initialize(response = nil)
                @response = response
                if @response && @response.body
                  @response_body = JSON.parse(@response.body)
                  super(@response_body['msg']) if @response_body['msg']
        Severity: Minor
        Found in lib/chatty_crow/error.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

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

            def self.execute(options, &resp_block)
              # Prepare options (url + headers)
              options[:url]     = contacts_url
              options[:headers] = ChattyCrow.default_headers(options.delete(:channel), options.delete(:token))
        
        
        Severity: Minor
        Found in lib/chatty_crow/contacts_request.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 file_base64 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

              def file_base64
                f = @file
        
                # ActionDispatch::Http::UploadedFile (get tempfile)
                if defined?(::ActionDispatch) && f.instance_of?(::ActionDispatch::Http::UploadedFile)
        Severity: Minor
        Found in lib/chatty_crow/request/mail.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