socketry/nio4r

View on GitHub

Showing 16 of 26 total issues

ByteBuffer has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

public class ByteBuffer extends RubyObject {
    private java.nio.ByteBuffer byteBuffer;

    public static RaiseException newOverflowError(ThreadContext context, String message) {
        RubyClass klass = context.runtime.getModule("NIO").getClass("ByteBuffer").getClass("OverflowError");
Severity: Minor
Found in ext/nio4r/org/nio4r/ByteBuffer.java - About 2 hrs to fix

    Method select has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
    Open

        def select(timeout = nil)
          selected_monitors = Set.new
    
          @lock.synchronize do
            readers = [@wakeup]
    Severity: Minor
    Found in lib/nio/selector.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

    Method symbolToInterestOps has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public static int symbolToInterestOps(Ruby ruby, SelectableChannel channel, IRubyObject interest) {
            if(interest == ruby.newSymbol("r")) {
                if((channel.validOps() & SelectionKey.OP_ACCEPT) != 0) {
                  return SelectionKey.OP_ACCEPT;
                } else {
    Severity: Minor
    Found in ext/nio4r/org/nio4r/Nio4r.java - 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

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

        def select(timeout = nil)
          selected_monitors = Set.new
    
          @lock.synchronize do
            readers = [@wakeup]
    Severity: Minor
    Found in lib/nio/selector.rb - About 1 hr to fix

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

          @JRubyMethod
          public IRubyObject register(ThreadContext context, IRubyObject io, IRubyObject interests) {
              Ruby runtime = context.getRuntime();
              Channel rawChannel = RubyIO.convertToIO(context, io).getChannel();
      
      
      Severity: Minor
      Found in ext/nio4r/org/nio4r/Selector.java - About 1 hr to fix

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

            private int doSelect(Ruby runtime, ThreadContext context, IRubyObject timeout) {
                int result;
        
                cancelKeys();
                try {
        Severity: Minor
        Found in ext/nio4r/org/nio4r/Selector.java - 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 select has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            @JRubyMethod
            public synchronized IRubyObject select(ThreadContext context, IRubyObject timeout, Block block) {
                Ruby runtime = context.getRuntime();
        
                if(!this.selector.isOpen()) {
        Severity: Minor
        Found in ext/nio4r/org/nio4r/Selector.java - About 1 hr to fix

          Method select has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              @JRubyMethod
              public synchronized IRubyObject select(ThreadContext context, IRubyObject timeout, Block block) {
                  Ruby runtime = context.getRuntime();
          
                  if(!this.selector.isOpen()) {
          Severity: Minor
          Found in ext/nio4r/org/nio4r/Selector.java - 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 register has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              @JRubyMethod
              public IRubyObject register(ThreadContext context, IRubyObject io, IRubyObject interests) {
                  Ruby runtime = context.getRuntime();
                  Channel rawChannel = RubyIO.convertToIO(context, io).getChannel();
          
          
          Severity: Minor
          Found in ext/nio4r/org/nio4r/Selector.java - 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 doSelect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private int doSelect(Ruby runtime, ThreadContext context, IRubyObject timeout) {
                  int result;
          
                  cancelKeys();
                  try {
          Severity: Minor
          Found in ext/nio4r/org/nio4r/Selector.java - About 1 hr to fix

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

                def initialize(io, interests, selector)
                  unless io.is_a? OpenSSL::SSL::SSLSocket
                    unless io.is_a?(IO)
                      if IO.respond_to? :try_convert
                        io = IO.try_convert(io)
            Severity: Minor
            Found in lib/nio/monitor.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 readFrom has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                @JRubyMethod(name = "read_from")
                public IRubyObject readFrom(ThreadContext context, IRubyObject io) {
                    Ruby runtime = context.runtime;
                    Channel channel = RubyIO.convertToIO(context, io).getChannel();
            
            
            Severity: Minor
            Found in ext/nio4r/org/nio4r/ByteBuffer.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 writeTo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                @JRubyMethod(name = "write_to")
                public IRubyObject writeTo(ThreadContext context, IRubyObject io) {
                    Ruby runtime = context.runtime;
                    Channel channel = RubyIO.convertToIO(context, io).getChannel();
            
            
            Severity: Minor
            Found in ext/nio4r/org/nio4r/ByteBuffer.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

            Avoid too many return statements within this method.
            Open

                          return SelectionKey.OP_ACCEPT;
            Severity: Major
            Found in ext/nio4r/org/nio4r/Nio4r.java - About 30 mins to fix

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

                  def close
                    @lock.synchronize do
                      return if @closed
              
                      begin
              Severity: Minor
              Found in lib/nio/selector.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 register has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

                  def register(io, interest)
                    unless io.is_a? OpenSSL::SSL::SSLSocket
                      io = IO.try_convert(io)
                    end
              
              
              Severity: Minor
              Found in lib/nio/selector.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

              Severity
              Category
              Status
              Source
              Language