cj/opal-webpack

View on GitHub

Showing 21 of 21 total issues

Method plus has a Cognitive Complexity of 38 (exceeds 5 allowed). Consider refactoring.
Open

    def plus(path1, path2) # -> path # :nodoc:
      prefix2 = path2
      index_list2 = []
      basename_list2 = []
      while r2 = chop_basename(prefix2)
Severity: Minor
Found in lib/compiler_patches/pathname.rb - About 5 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 relative_path_from has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
Open

    def relative_path_from(base_directory)
      dest_directory = self.cleanpath.to_s
      base_directory = base_directory.cleanpath.to_s
      dest_prefix = dest_directory
      dest_names = []
Severity: Minor
Found in lib/compiler_patches/pathname.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

Function exports has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

module.exports = function (source, options, context) {
  /*
    Workaround to make IO work,
    webpack polyfill global "process" module by default,
    while Opal::IO rely on it to deterimine in node environment or not
Severity: Minor
Found in lib/transpile.js - 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

Function exports has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

module.exports = function(source) {
  var result = {}

  const filename = this.resourcePath
  const globalOptions = this.options.opal || {}
Severity: Major
Found in index.js - About 2 hrs to fix

    Method basename has 50 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

          def basename(name, suffix=nil)
            %x{
              var p, q, e, f = 0, n = -1, tmp, pointerMath, origName;
    
              if (name === nil) {
    Severity: Minor
    Found in lib/compiler_patches/file.rb - About 2 hrs to fix

      Method encode has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

            def self.encode(ary)
              result = []
              ary.each do |n|
                vlq = n < 0 ? ((-n) << 1) + 1 : n << 1
                loop do
      Severity: Minor
      Found in lib/compiler_patches/source_maps.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 join has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          def join(*args)
            return self if args.empty?
            result = args.pop
            result = Pathname.new(result) unless Pathname === result
            return result if result.absolute?
      Severity: Minor
      Found in lib/compiler_patches/pathname.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 extname has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

            def extname(path)
              raise TypeError, 'no implicit conversion of nil into String' if path.nil?
              path = path.to_path if path.respond_to?(:to_path)
              raise TypeError, "no implicit conversion of #{path.class} into String" unless path.is_a?(String)
              filename = basename(path)
      Severity: Minor
      Found in lib/compiler_patches/file.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 plus has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          def plus(path1, path2) # -> path # :nodoc:
            prefix2 = path2
            index_list2 = []
            basename_list2 = []
            while r2 = chop_basename(prefix2)
      Severity: Minor
      Found in lib/compiler_patches/pathname.rb - About 1 hr to fix

        Function exports has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        module.exports = function (source, options, context) {
          /*
            Workaround to make IO work,
            webpack polyfill global "process" module by default,
            while Opal::IO rely on it to deterimine in node environment or not
        Severity: Minor
        Found in lib/transpile.js - About 1 hr to fix

          Method relative_path_from has 33 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              def relative_path_from(base_directory)
                dest_directory = self.cleanpath.to_s
                base_directory = base_directory.cleanpath.to_s
                dest_prefix = dest_directory
                dest_names = []
          Severity: Minor
          Found in lib/compiler_patches/pathname.rb - About 1 hr to fix

            Function createBundledCompiler has 28 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function createBundledCompiler(filename) {
              const env = process.env
              console.log(`Bundle derived compiler ${filename} doesn't exist. Creating!`)
              const compilerPath = path.resolve(__dirname, 'compiler.rb')
              // our patches live in lib / same directory as this file
            Severity: Minor
            Found in lib/getOpalCompilerFilename.js - About 1 hr to fix

              Method dirname has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def dirname(path)
                      %x{
                        if (path === nil) {
                          #{raise TypeError, 'no implicit conversion of nil into String'}
                        }
              Severity: Minor
              Found in lib/compiler_patches/file.rb - About 1 hr to fix

                Function exports has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                var cache = module.exports = function(params, callback) {
                  // Spread params into named variables
                  // Forgive user whenever possible
                  var source = params.source;
                  var options = params.options || {};
                Severity: Minor
                Found in lib/fs-cache.js - About 1 hr to fix

                  Function read has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                  var read = function(filename, callback) {
                    return fs.readFile(filename, function(err, data) {
                      if (err) { return callback(err); }
                  
                      return zlib.gunzip(data, function(err, content) {
                  Severity: Minor
                  Found in lib/fs-cache.js - 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 expand_path has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                        def expand_path(path, basedir = nil)
                          path = [basedir, path].compact.join(SEPARATOR)
                          parts = path.split(SEPARATOR)
                          new_parts = []
                          parts[0] = Dir.home if parts.first == '~'
                  Severity: Minor
                  Found in lib/compiler_patches/file.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 8 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def initialize(path)
                        if Pathname === path
                          @path = path.path.to_s
                        elsif path.respond_to?(:to_path)
                          @path = path.to_path
                  Severity: Minor
                  Found in lib/compiler_patches/pathname.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

                  Function exports has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  module.exports = function(compiler, source, resourcePath, rawResult, generatedSource) {
                  Severity: Minor
                  Found in lib/processSourceMaps.js - About 35 mins to fix

                    Function exports has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    module.exports = function(source) {
                      var result = {}
                    
                      const filename = this.resourcePath
                      const globalOptions = this.options.opal || {}
                    Severity: Minor
                    Found in index.js - 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

                    Function getRubyOutput has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                    Open

                    function getRubyOutput(mriRequires) {
                      const stubCode = opalVersion.indexOf('0.9') == -1 ? 'Opal::Config.stubbed_files' : 'Opal::Processor.stubbed_files'
                      const flatRequires = mriRequires.map(req => `require '${req}'`).join(';')
                      const mriPathsVariable = env.RAILS_ENV ? 'Rails.application.assets.paths' : 'Opal.paths'
                      const rubyCode = `${flatRequires}; puts({loadPath: ${mriPathsVariable}, stubs: ${stubCode}.to_a}.to_json)`
                    Severity: Minor
                    Found in lib/getRubyMetadata.js - 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

                    Severity
                    Category
                    Status
                    Source
                    Language