mongodb/bson-ruby

View on GitHub
src/main/org/bson_ruby/ByteBuf.java

Summary

Maintainability
C
1 day
Test Coverage

File ByteBuf.java has 422 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * Copyright (C) 2015-2020 MongoDB Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
Severity: Minor
Found in src/main/org/bson_ruby/ByteBuf.java - About 6 hrs to fix

    ByteBuf has 36 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class ByteBuf extends RubyObject {
    
      /**
       * Constant for a null byte.
       */
    Severity: Minor
    Found in src/main/org/bson_ruby/ByteBuf.java - About 4 hrs to fix

      Method writeCharacters has 28 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

        private int writeCharacters(final String string) {
          int len = string.length();
          int total = 0;
      
          for (int i = 0; i < len;) {
      Severity: Minor
      Found in src/main/org/bson_ruby/ByteBuf.java - About 1 hr to fix

        Method putCString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

          @JRubyMethod(name = "put_cstring")
          public ByteBuf putCString(ThreadContext context, final IRubyObject value) throws UnsupportedEncodingException {
        
            if (value instanceof RubyFixnum) {
              RubyString str = ((RubyFixnum) value).to_s();
        Severity: Minor
        Found in src/main/org/bson_ruby/ByteBuf.java - 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 writeCharacters has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

          private int writeCharacters(final String string) {
            int len = string.length();
            int total = 0;
        
            for (int i = 0; i < len;) {
        Severity: Minor
        Found in src/main/org/bson_ruby/ByteBuf.java - 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

        There are no issues that match your filters.

        Category
        Status