akicho8/rasl

View on GitHub

Showing 20 of 20 total issues

File rasl.rb has 1386 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'optparse'
require 'pathname'
require 'readline'
require 'kconv'

Severity: Major
Found in lib/rasl.rb - About 3 days to fix

    Class Value has 21 methods (exceeds 20 allowed). Consider refactoring.
    Open

      class Value
        class << self
          def cast_value(value, signed)
            format = {8 => 'c', 16 => 's', 32 => 'l', 64 => 'q'}.fetch(Value.bit)
            [value].pack(format).unpack(signed ? format : format.upcase).first
    Severity: Minor
    Found in lib/rasl.rb - About 2 hrs to fix

      Method operand_list has 53 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def operand_list
            [
              { key: :nop,  op_code: 0x09, encode: :encode_blank,                decode: :decode_nop                                      },
      
              { key: :ld,   op_code: 0x10, encode: :encode_rix,  with_imm: true, decode: :decode_ld_rix,   printer: :prt_rix              },
      Severity: Major
      Found in lib/rasl.rb - About 2 hrs to fix

        Method parser has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            def parser
              OptionParser.new do |o|
                o.version = VERSION
                o.banner = [
                  "CASL Assembler / Simulator #{o.ver}\n",
        Severity: Minor
        Found in lib/rasl.rb - About 1 hr to fix

          Method parse_order_part has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

              def parse_order_part
                if str = @scanner.scan(syntax[:symbol])
                  @encoded = false
                  skip_blank
                  pointer = @scanner.pointer
          Severity: Minor
          Found in lib/rasl.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 simulator has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def simulator
                command_init
                loop do
                  if defined? Readline
                    getline(Readline.readline('-'))
          Severity: Minor
          Found in lib/rasl.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 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def execute(args)
                begin
                  parser.parse!(args)
                rescue OptionParser::InvalidOption => error
                  puts error
          Severity: Minor
          Found in lib/rasl.rb - About 1 hr to fix

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

                def execute(args)
                  begin
                    parser.parse!(args)
                  rescue OptionParser::InvalidOption => error
                    puts error
            Severity: Minor
            Found in lib/rasl.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 assemble_once has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def assemble_once
                  Rasl::Parser.line_count = nil
            
                  @code_size = 0
                  @boot_pc = nil
            Severity: Minor
            Found in lib/rasl.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 scan_imm has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

                def scan_imm
                  case
                  when str = @scanner.scan(syntax[:label])
                    if @pass_count == 0
                      undecision
            Severity: Minor
            Found in lib/rasl.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 assemble_once has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def assemble_once
                  Rasl::Parser.line_count = nil
            
                  @code_size = 0
                  @boot_pc = nil
            Severity: Minor
            Found in lib/rasl.rb - About 1 hr to fix

              Method current_file_line has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def current_file_line
                    if Rasl::Parser.line_count
                      if ARGF.filename == '-'
                        path = '<STDIN>'
                      else
              Severity: Minor
              Found in lib/rasl.rb - About 55 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 parse_label_part has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  def parse_label_part
                    @current_label = nil
                    if label = @scanner.scan(/#{syntax[:label]}:?/)
                      if Rasl.config.bol_order && !label.end_with?(':') && @operands.collect(&:match_names).flatten.include?(label.downcase)
                        @scanner.unscan
              Severity: Minor
              Found in lib/rasl.rb - About 55 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 store_object has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  def store_object(gr: nil, imm: nil, xr: nil)
                    raise SyntaxError if (gr && !gr.pos) || (gr && !gr.pos)
                    store_prim_op(@current_op.op_code, (gr ? gr.pos : nil), (xr ? xr.pos : nil), imm)
                  end
              Severity: Minor
              Found in lib/rasl.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 store_object has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def store_object(gr: nil, imm: nil, xr: nil)
                    raise SyntaxError if gr && !gr.pos
                    raise SyntaxError if xr && !xr.pos
                    store_prim_op(@current_op.op_code, (gr ? gr.pos : nil), (xr ? xr.pos : nil), imm)
                  end
              Severity: Minor
              Found in lib/rasl.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 scan_xr has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
              Open

                  def scan_xr
                    skip_sep
                    if str = @scanner.scan(register_regexp)
                      xr = @gr[str.downcase]
                      unless xr
              Severity: Minor
              Found in lib/rasl.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 scan_str_literal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def scan_str_literal(mark)
                    if @scanner.check(/#{mark}/)
                      from = @scanner.pointer
                      nil while @scanner.scan(/#{mark}[^#{mark}]*#{mark}/) && @scanner.check(/#{mark}/)
                      str = @scanner.string[from...@scanner.pointer] # 【'a''b'】
              Severity: Minor
              Found in lib/rasl.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 prefetch has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def prefetch(pc)
                    attrs = {}
              
                    attrs[:addr] = pc
                    attrs[:raw] = mem_get(pc)
              Severity: Minor
              Found in lib/rasl.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

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

                  def store_prim_op(op_code, r1, r2, imm = nil)
                    store_value((op_code << 8) | (((r1 || 0) & 0xf) << 4) | ((r2 || 0) & 0xf))
                    if imm
                      store_value(imm)
              Severity: Minor
              Found in lib/rasl.rb and 1 other location - About 15 mins to fix
              lib/rasl.rb on lines 359..362

              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 26.

              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

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

                  def store_prim_op(op_code, r1, r2, imm = nil)
                    store_value((op_code << 8) | (((r1 || 0) & 0xf) << 4) | ((r2 || 0) & 0xf))
                    if imm
                      store_value(imm)
              Severity: Minor
              Found in lib/rasl.rb and 1 other location - About 15 mins to fix
              lib/rasl.rb on lines 577..580

              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 26.

              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