rubinius/rubinius

View on GitHub

Showing 1,541 of 1,541 total issues

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

  def sub!(pattern, replacement=undefined)
    # Because of the behavior of $~, this is duplicated from sub! because
    # if we call sub! from sub, the last_match can't be updated properly.

    unless valid_encoding?
Severity: Minor
Found in core/string.rb - About 4 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

Class Complex has 34 methods (exceeds 20 allowed). Consider refactoring.
Open

class Complex < Numeric

  undef_method :%
  undef_method :<
  undef_method :<=
Severity: Minor
Found in core/complex.rb - About 4 hrs to fix

    Method alien has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def alien(gems=[])
        errors = Hash.new { |h,k| h[k] = {} }
    
        Gem::Specification.each do |spec|
          next unless gems.include? spec.name unless gems.empty?
    Severity: Minor
    Found in library/rubygems/validator.rb - About 4 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 generate has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

          def generate
            typedefs = BodyGuard.new(self, "ffi_types_generator", @platform).perform
    
            code = ""
    
    
    Severity: Minor
    Found in library/ffi/generators/types.rb - About 4 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 setup_llvm has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def setup_llvm
        @log.print "  Checking for 'llvm-config': "
    
        config = @llvm_configure
        if !config
    Severity: Minor
    Found in configure.rb - About 4 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 puts has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def puts(*args)
        if args.empty?
          write DEFAULT_RECORD_SEPARATOR
        else
          args.each do |arg|
    Severity: Minor
    Found in core/io.rb - About 4 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 reopen has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def reopen(other, mode=undefined)
        if other.respond_to?(:to_io)
          flush
    
          if other.kind_of? IO
    Severity: Minor
    Found in core/io.rb - About 4 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 strip_bom has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def strip_bom
        return unless File::Stat.fstat(descriptor).file?
    
        case b1 = getbyte
        when 0x00
    Severity: Minor
    Found in core/io.rb - About 4 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 read has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def read(bytes=nil, output=nil)
          # The user might try to pass in nil, so we have to check here
          output ||= default_value
          output.clear
    
    
    Severity: Minor
    Found in core/argf.rb - About 4 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 trap has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def self.trap(sig, prc=nil, &block)
        sig = sig.to_s if sig.kind_of?(Symbol)
    
        if sig.kind_of?(String)
          osig = sig
    Severity: Minor
    Found in core/signal.rb - About 4 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 round has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

      def round(ndigits=undefined)
        return self if undefined.equal? ndigits
    
        if ndigits.kind_of? Numeric
          if ndigits > Fixnum::MAX or ndigits <= Fixnum::MIN
    Severity: Minor
    Found in core/integer.rb - About 4 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

    File dir_glob.rb has 342 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    class Dir
      module Glob
        class Node
          def initialize(nxt, flags)
            @flags = flags
    Severity: Minor
    Found in core/dir_glob.rb - About 4 hrs to fix

      Method require has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def require path
          RUBYGEMS_ACTIVATION_MONITOR.enter
      
          path = path.to_path if path.respond_to? :to_path
      
      
      Severity: Minor
      Found in library/rubygems/core_ext/kernel_require.rb - About 4 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 open_class_under has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def self.open_class_under(name, sup, mod)
          unless Type.object_kind_of? mod, Module
            raise TypeError, "'#{mod.inspect}' is not a class/module"
          end
      
      
      Severity: Minor
      Found in core/zed.rb - About 4 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 succ! has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def succ!
          self.modify!
      
          return self if @num_bytes == 0
      
      
      Severity: Minor
      Found in core/string.rb - About 4 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 find_const has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
      Open

        def find_const(under)
          current = under
          constant = undefined
      
          while current
      Severity: Minor
      Found in core/autoload.rb - About 4 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

      File user_interaction.rb has 335 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      require 'rubygems/util'
      
      ##
      # Module that defines the default UserInteraction.  Any class including this
      # module will have access to the +ui+ method that returns the default UI.
      Severity: Minor
      Found in library/rubygems/user_interaction.rb - About 4 hrs to fix

        Method setup has 100 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          def setup
            super
        
            @orig_gem_home   = ENV['GEM_HOME']
            @orig_gem_path   = ENV['GEM_PATH']
        Severity: Major
        Found in library/rubygems/test_case.rb - About 4 hrs to fix

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            module UID
              class << self
                def change_privilege(uid)
                  uid = Rubinius::Type.coerce_to uid, Integer, :to_int
          
          
          Severity: Major
          Found in core/process.rb and 1 other location - About 4 hrs to fix
          core/process.rb on lines 732..788

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 137.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Similar blocks of code found in 2 locations. Consider refactoring.
          Open

            module GID
              class << self
                def change_privilege(gid)
                  gid = Rubinius::Type.coerce_to gid, Integer, :to_int
          
          
          Severity: Major
          Found in core/process.rb and 1 other location - About 4 hrs to fix
          core/process.rb on lines 669..725

          Duplicated Code

          Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

          Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

          When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

          Tuning

          This issue has a mass of 137.

          We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

          The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

          If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

          See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

          Refactorings

          Further Reading

          Severity
          Category
          Status
          Source
          Language