stellar/xdrgen

View on GitHub

Showing 147 of 147 total issues

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

        ref = case type.sub_type
        when :simple
          if cyclic
            "Box<#{base_ref}>"
          else
Severity: Major
Found in lib/xdrgen/generators/rust.rb and 1 other location - About 2 hrs to fix
lib/xdrgen/generators/rust.rb on lines 940..964

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

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

        case type.sub_type
        when :simple
          if cyclic
            "Box<#{base_ref}>"
          else
Severity: Major
Found in lib/xdrgen/generators/rust.rb and 1 other location - About 2 hrs to fix
lib/xdrgen/generators/rust.rb on lines 1018..1042

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

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

Method build_type_args has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

      def build_type_args(type)
        base_ref = case type
          when AST::Typespecs::Bool
            "Bool"
          when AST::Typespecs::Double
Severity: Minor
Found in lib/xdrgen/generators/elixir.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

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

        union.arms.each do |arm|
          case arm
            when AST::Definitions::UnionDefaultArm ;
              out.puts "default:"
            else
Severity: Major
Found in lib/xdrgen/generators/java.rb and 1 other location - About 1 hr to fix
lib/xdrgen/generators/java.rb on lines 554..573

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

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

        union.arms.each do |arm|
          case arm
            when AST::Definitions::UnionDefaultArm ;
              out.puts "default:"
            else
Severity: Major
Found in lib/xdrgen/generators/java.rb and 1 other location - About 1 hr to fix
lib/xdrgen/generators/java.rb on lines 598..617

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

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

Method add_imports_for_definition has 44 lines of code (exceeds 25 allowed). Consider refactoring.
Open

      def add_imports_for_definition(defn, imports)
        imports.add("org.stellar.sdk.Base64Factory")
        imports.add("java.io.ByteArrayInputStream")
        imports.add("java.io.ByteArrayOutputStream")

Severity: Minor
Found in lib/xdrgen/generators/java.rb - About 1 hr to fix

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

          def render_union_typedef(out, typedef, union)
            out.puts <<-EOS.strip_heredoc
              // SwitchFieldName returns the field name in which this union's
              // discriminant is stored
              func (u #{name typedef}) SwitchFieldName() string {
    Severity: Minor
    Found in lib/xdrgen/generators/go.rb - About 1 hr to fix

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

            def render_definition(out, defn)
              if @already_rendered.include? name(defn)
      
                unless defn.is_a?(AST::Definitions::Namespace)
                  $stderr.puts "warn: #{name(defn)} is defined twice.  skipping"
      Severity: Minor
      Found in lib/xdrgen/generators/go.rb - About 1 hr to fix

        Method base_reference has 42 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

              def base_reference(type)
                case type
                when AST::Typespecs::Bool
                  'bool'
                when AST::Typespecs::Double
        Severity: Minor
        Found in lib/xdrgen/generators/rust.rb - About 1 hr to fix

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

                  union.arms.each do |arm|
                    case arm
                    when AST::Definitions::UnionDefaultArm
                      out.puts 'default:'
                    else
          Severity: Major
          Found in lib/xdrgen/generators/csharp.rb and 1 other location - About 1 hr to fix
          lib/xdrgen/generators/csharp.rb on lines 223..237

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

          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

                  union.arms.each do |arm|
                    case arm
                    when AST::Definitions::UnionDefaultArm
                      out.puts 'default:'
                    else
          Severity: Major
          Found in lib/xdrgen/generators/csharp.rb and 1 other location - About 1 hr to fix
          lib/xdrgen/generators/csharp.rb on lines 253..267

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

          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

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

                def base_reference(type)
                  case type
                  when AST::Typespecs::Bool
                    'bool'
                  when AST::Typespecs::Double
          Severity: Minor
          Found in lib/xdrgen/generators/rust.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 reference has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def reference(parent, type)
                  base_ref = base_reference type
          
                  parent_name = name(parent) if parent
                  cyclic = is_type_in_type_field_types(base_ref, parent_name)
          Severity: Minor
          Found in lib/xdrgen/generators/rust.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 render_union has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def render_union(union)
          
                  render_element "class", union, "< XDR::Union" do |out|
                    render_nested_definitions out, union
          
          
          Severity: Minor
          Found in lib/xdrgen/generators/ruby.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 base_reference_to_call has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def base_reference_to_call(type)
                  case type
                  when AST::Typespecs::String
                    if !type.decl.resolved_size.nil?
                      "StringM::<#{type.decl.resolved_size}>"
          Severity: Minor
          Found in lib/xdrgen/generators/rust.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 encode_member has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

                def encode_member(member, out, is_union_member = false)
                  case member.declaration
                  when AST::Declarations::Void
                    out.puts "return"
                  end
          Severity: Minor
          Found in lib/xdrgen/generators/python.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 render_typedef has 39 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                def render_typedef(typedef)
                  typedef_name = typedef.name.camelize
                  typedef_name_underscore = typedef.name.underscore
          
                  @init_out.puts "from .#{typedef_name_underscore} import #{typedef_name}"
          Severity: Minor
          Found in lib/xdrgen/generators/python.rb - About 1 hr to fix

            Method render_union has 39 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                  def render_union(out, union)
                    out.puts "xdr.union(\"#{name union}\", {"
                    out.indent do
                      out.puts "switchOn: #{reference union.discriminant.type},"
                      out.puts "switchName: \"#{member_name union.discriminant}\","
            Severity: Minor
            Found in lib/xdrgen/generators/javascript.rb - About 1 hr to fix

              Method render_struct has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                    def render_struct(out, struct)
                      out.puts "#[derive(Clone, Debug, Hash, PartialEq, Eq, PartialOrd, Ord)]"
                      out.puts %{#[cfg_attr(feature = "arbitrary", derive(Arbitrary))]}
                      if @options[:rust_types_custom_str_impl].include?(name struct)
                        out.puts %{#[cfg_attr(all(feature = "serde", feature = "alloc"), derive(serde_with::SerializeDisplay, serde_with::DeserializeFromStr))]}
              Severity: Minor
              Found in lib/xdrgen/generators/rust.rb - About 1 hr to fix

                Method render_union has 37 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                      def render_union(out, union)
                
                        out.puts "type #{name union} struct{"
                        out.indent do
                          out.puts "#{name union.discriminant} #{reference union.discriminant.type}"
                Severity: Minor
                Found in lib/xdrgen/generators/go.rb - About 1 hr to fix
                  Severity
                  Category
                  Status
                  Source
                  Language