ogawatti/twimock

View on GitHub

Showing 16 of 16 total issues

Class Table has 37 methods (exceeds 20 allowed). Consider refactoring.
Open

    class Table
      # 以下は継承先でオーバーライド必須
      #  * TABLE_NAME, COLUMN_NAMES
      #  * initialize()
      TABLE_NAME = :tables
Severity: Minor
Found in lib/twimock/database/table.rb - About 4 hrs to fix

    File table.rb has 302 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    require 'twimock/database'
    require 'sqlite3'
    require 'hashie'
    
    module Twimock
    Severity: Minor
    Found in lib/twimock/database/table.rb - About 3 hrs to fix

      Method update! has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
      Open

            def update!(options={})
              if options.empty?
                column_names.each do |column_name|
                  if (value = self.send(column_name)) && column_name != :id
                    options[column_name] = value unless options.nil?
      Severity: Minor
      Found in lib/twimock/database/table.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 call has 44 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

              def call(env)
                return super unless called?(env)
                begin
                  request = Rack::Request.new(env)
                  body = query_string_to_hash(request.body.read)
      Severity: Minor
      Found in lib/twimock/api/intent/sessions.rb - About 1 hr to fix

        Method call has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

                def call(env)
                  return super unless called?(env)
                  begin
                    authorization_header = env["authorization"] || env["HTTP_AUTHORIZATION"]
                    oauth = parse_authorization_header(authorization_header)
        Severity: Minor
        Found in lib/twimock/api/oauth/access_token.rb - About 1 hr to fix

          Method method_missing has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

                def method_missing(name, *args)
                  method_name = name.to_s.include?("=") ? name.to_s[0...-1].to_sym : name
                  case name
                  when :identifier  then return send(:id)
                  when :identifier= then return send(:id=, *args)
          Severity: Minor
          Found in lib/twimock/database/table.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 load_users has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              def load_users(ymlfile)
                load_data = YAML.load_file(ymlfile)
                raise Twimock::Errors::IncorrectDataFormat.new "data is not Array" unless load_data.kind_of?(Array)
          
                load_data.each do |app_data|
          Severity: Minor
          Found in lib/twimock/config.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 method_missing has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

                def self.method_missing(name, *args)
                  if ((name =~ /^find_by_(.+)/ || name =~ /^find_all_by_(.+)/) && 
                    (column_name = $1) && column_names.include?(column_name.to_sym))
                    raise ArgumentError, "wrong number of arguments (#{args.size} for 1)" unless args.size == 1
                    define_find_method(name, column_name) ? send(name, args.first) : super
          Severity: Minor
          Found in lib/twimock/database/table.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 load_users has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def load_users(ymlfile)
                load_data = YAML.load_file(ymlfile)
                raise Twimock::Errors::IncorrectDataFormat.new "data is not Array" unless load_data.kind_of?(Array)
          
                load_data.each do |app_data|
          Severity: Minor
          Found in lib/twimock/config.rb - About 1 hr to fix

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

                    def call(env)
                      return super unless called?(env)
                      begin
                        request = Rack::Request.new(env)
                        body = query_string_to_hash(request.body.read)
            Severity: Minor
            Found in lib/twimock/api/intent/sessions.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 call has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
            Open

                    def call(env)
                      return super unless called?(env)
                      begin
                        authorization_header = env["authorization"] || env["HTTP_AUTHORIZATION"]
                        oauth = parse_authorization_header(authorization_header)
            Severity: Minor
            Found in lib/twimock/api/oauth/access_token.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_access_token has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def validate_access_token(access_token_string, application_id)
                    return false if access_token_string.blank?
                    return false unless access_token = Twimock::AccessToken.find_by_string(access_token_string)
                    return false unless access_token.application_id
                    return false unless access_token.application_id == application_id
            Severity: Minor
            Found in lib/twimock/api/oauth.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 insert! has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                  def insert!(options={})
                    opts = Hashie::Mash.new(options)
                    instance = self.class.new
                    column_names.each do |column_name|
                      next if column_name == :created_at
            Severity: Minor
            Found in lib/twimock/database/table.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 auth_hash has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

              def auth_hash(access_token_string=nil)
                return Twimock::AuthHash.new unless validate_access_token_string(access_token_string)
            
                if access_token = Twimock::AccessToken.find_by_string(access_token_string)
                  if user = Twimock::User.find_by_id(access_token.user_id)
            Severity: Minor
            Found in lib/twimock.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 call has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def call(env)
                      return super unless called?(env)
            
                      begin
                        authorization_header = env["authorization"] || env["HTTP_AUTHORIZATION"]
            Severity: Minor
            Found in lib/twimock/api/account/verify_credentials.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_request_token has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                    def validate_request_token(request_token, application_id)
                      return false unless super(request_token)
            
                      request_token = Twimock::RequestToken.find_by_string(request_token)
                      return false unless request_token.application_id == application_id
            Severity: Minor
            Found in lib/twimock/api/oauth/access_token.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