axsh/wakame-vdc

View on GitHub
dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb

Summary

Maintainability
F
5 days
Test Coverage

Method upload_image has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

      def upload_image(inst, ctx, bo, evcb)
        @ctx = ctx
        @bo = bo

        Task::TaskSession.current[:backup_storage] = bo[:backup_storage]
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.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 upload_volume has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

      def upload_volume(ctx, volume, bo, evcb)
        @ctx = ctx
        @bo = bo

        Task::TaskSession.current[:backup_storage] = bo[:backup_storage]
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.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

File linux_local_store.rb has 385 lines of code (exceeds 250 allowed). Consider refactoring.
Open

require 'tmpdir'
require 'tempfile'
require 'uri'

module Dcmgr
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb - About 5 hrs to fix

Method upload_image has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def upload_image(inst, ctx, bo, evcb)
        @ctx = ctx
        @bo = bo

        Task::TaskSession.current[:backup_storage] = bo[:backup_storage]
Severity: Major
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb - About 2 hrs to fix

Method upload_volume has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def upload_volume(ctx, volume, bo, evcb)
        @ctx = ctx
        @bo = bo

        Task::TaskSession.current[:backup_storage] = bo[:backup_storage]
Severity: Major
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb - About 2 hrs to fix

Method deploy_volume has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def deploy_volume(hva_ctx, volume, backup_object, opts={:cache=>false})
        @ctx = hva_ctx
        @volume = volume
        FileUtils.mkdir(@ctx.inst_data_dir) unless File.exists?(@ctx.inst_data_dir)

Severity: Major
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb - About 2 hrs to fix

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

      def deploy_volume(hva_ctx, volume, backup_object, opts={:cache=>false})
        @ctx = hva_ctx
        @volume = volume
        FileUtils.mkdir(@ctx.inst_data_dir) unless File.exists?(@ctx.inst_data_dir)

Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.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 download_to_local_cache has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

      def download_to_local_cache(bo, volume)
        delete_local_cache()
        begin
          if File.mtime(vmimg_cache_path(volume[:volume_device][:path])) <= File.mtime("#{vmimg_cache_path(volume[:volume_device][:path])}.md5")
            cached_chksum = File.read("#{vmimg_cache_path(volume[:volume_device][:path])}.md5").chomp
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.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 download_to_local_cache has 34 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def download_to_local_cache(bo, volume)
        delete_local_cache()
        begin
          if File.mtime(vmimg_cache_path(volume[:volume_device][:path])) <= File.mtime("#{vmimg_cache_path(volume[:volume_device][:path])}.md5")
            cached_chksum = File.read("#{vmimg_cache_path(volume[:volume_device][:path])}.md5").chomp
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb - About 1 hr to fix

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

      def archive_from_snapshot(ctx, snapshot_path, &blk)
        tmpdir = Dir.mktmpdir(nil, ctx.inst_data_dir)
        chksum_path = File.expand_path('md5', tmpdir)
        size_path = File.expand_path('size', tmpdir)

Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb - About 1 hr to fix

Method detect_container_type has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

      def detect_container_type(path)
        # use the file command to detect if the image file is gzip
        # commpressed.
        raise "File does not exist: #{path}" unless File.exist?(path)
        file_type1=shell.run!("/usr/bin/file -b %s", [path]).out
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.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

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

        if @bkst_drv_class.include?(BackupStorage::CommandAPI)
          archive_from_snapshot(@ctx, @snapshot_path) do |cmd_tuple, chksum_path, size_path|
            cmd_tuple2 = invoke_task(@bkst_drv_class,
                                     :upload_command, [nil, bo])

Severity: Major
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb and 1 other location - About 6 hrs to fix
dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb on lines 231..301

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

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

        if @bkst_drv_class.include?(BackupStorage::CommandAPI)
          archive_from_snapshot(@ctx, @snapshot_path) do |cmd_tuple, chksum_path, size_path|
            cmd_tuple2 = invoke_task(@bkst_drv_class,
                                     :upload_command, [nil, bo])

Severity: Major
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb and 1 other location - About 6 hrs to fix
dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb on lines 141..211

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

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

        when :tgz
          Dir.mktmpdir(nil, @ctx.inst_data_dir) { |tmpdir|
            cmd_tuple[0] << "| #{pv_command} tar -zxS -C %s"
            cmd_tuple[1] += [tmpdir]
            shell.run!(*cmd_tuple)
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb and 1 other location - About 45 mins to fix
dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb on lines 94..102

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

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

        when :tar
          Dir.mktmpdir(nil, @ctx.inst_data_dir) { |tmpdir|
            cmd_tuple[0] << "| #{pv_command} tar -xS -C %s"
            cmd_tuple[1] += [tmpdir]
            shell.run!(*cmd_tuple)
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb and 1 other location - About 45 mins to fix
dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb on lines 79..87

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

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

        suffix = Const::BackupObject::CONTAINER_EXTS.keys.find { |i|
          i = ".#{i}" if i !~ /^\./
          File.basename(path)[-i.size, i.size] == i
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb and 1 other location - About 20 mins to fix
dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb on lines 435..437

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

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

        suffix = Const::BackupObject::CONTAINER_EXTS.keys.find { |i|
          i = ".#{i}" if i !~ /^\./
          File.basename(path)[-i.size, i.size] == i
Severity: Minor
Found in dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb and 1 other location - About 20 mins to fix
dcmgr/lib/dcmgr/drivers/local_store/linux_local_store.rb on lines 335..337

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

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

There are no issues that match your filters.

Category
Status