ogawatti/facemock

View on GitHub
lib/facemock/database/table.rb

Summary

Maintainability
D
1 day
Test Coverage

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/facemock/database/table.rb - About 4 hrs to fix

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

    require 'facemock/database'
    require 'sqlite3'
    require 'hashie'
    
    module Facemock
    Severity: Minor
    Found in lib/facemock/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/facemock/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 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/facemock/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 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/facemock/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 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/facemock/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

      There are no issues that match your filters.

      Category
      Status