eventmachine/eventmachine

View on GitHub
java/src/com/rubyeventmachine/EmReactor.java

Summary

Maintainability
F
3 days
Test Coverage

File EmReactor.java has 478 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * $Id$
 * 
 * Author:: Francis Cianfrocca (gmail: blackhedd)
 * Homepage:: http://rubyeventmachine.com
Severity: Minor
Found in java/src/com/rubyeventmachine/EmReactor.java - About 7 hrs to fix

    EmReactor has 47 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public class EmReactor implements EmReactorInterface
    {
        private static final NullEventableChannel NULL_EVENTABLE_CHANNEL = new NullEventableChannel();
        public final int EM_TIMER_FIRED = 100;
        public final int EM_CONNECTION_READ = 101;
    Severity: Minor
    Found in java/src/com/rubyeventmachine/EmReactor.java - About 6 hrs to fix

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

          void close() {
              try {
                  if (mySelector != null)
                      mySelector.close();
              } catch (IOException e) {}
      Severity: Minor
      Found in java/src/com/rubyeventmachine/EmReactor.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 isAcceptable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
      Open

          void isAcceptable (SelectionKey k) {
              ServerSocketChannel ss = (ServerSocketChannel) k.channel();
              SocketChannel sn;
              long b;
      
      
      Severity: Minor
      Found in java/src/com/rubyeventmachine/EmReactor.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 close has 35 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          void close() {
              try {
                  if (mySelector != null)
                      mySelector.close();
              } catch (IOException e) {}
      Severity: Minor
      Found in java/src/com/rubyeventmachine/EmReactor.java - About 1 hr to fix

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

            void processIO() {
                Iterator<SelectionKey> it = mySelector.selectedKeys().iterator();
                while (it.hasNext()) {
                    SelectionKey k = it.next();
                    it.remove();
        Severity: Minor
        Found in java/src/com/rubyeventmachine/EmReactor.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 isAcceptable has 28 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            void isAcceptable (SelectionKey k) {
                ServerSocketChannel ss = (ServerSocketChannel) k.channel();
                SocketChannel sn;
                long b;
        
        
        Severity: Minor
        Found in java/src/com/rubyeventmachine/EmReactor.java - About 1 hr to fix

          Method isReadable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              void isReadable (SelectionKey k) {
                  EventableChannel ec = (EventableChannel) k.attachment();
                  long b = ec.getBinding();
          
                  if (ec.isWatchOnly()) {
          Severity: Minor
          Found in java/src/com/rubyeventmachine/EmReactor.java - 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 isWritable has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
          Open

              void isWritable (SelectionKey k) {
                  EventableChannel ec = (EventableChannel) k.attachment();
                  long b = ec.getBinding();
          
                  if (ec.isWatchOnly()) {
          Severity: Minor
          Found in java/src/com/rubyeventmachine/EmReactor.java - 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 sendDatagram has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public void sendDatagram (long sig, byte[] data, int length, String recipAddress, int recipPort) {
          Severity: Minor
          Found in java/src/com/rubyeventmachine/EmReactor.java - About 35 mins to fix

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

                void removeUnboundConnections() {
                    ListIterator<Long> iter = UnboundConnections.listIterator(0);
                    while (iter.hasNext()) {
                        long b = iter.next();
            
            
            Severity: Minor
            Found in java/src/com/rubyeventmachine/EmReactor.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 checkIO has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                void checkIO() {
                    long timeout;
            
                    if (NewConnections.size() > 0) {
                        timeout = -1;
            Severity: Minor
            Found in java/src/com/rubyeventmachine/EmReactor.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 addNewConnections has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                void addNewConnections() {
                    ListIterator<EventableSocketChannel> iter = DetachedConnections.listIterator(0);
                    while (iter.hasNext()) {
                        EventableSocketChannel ec = iter.next();
                        ec.cleanup();
            Severity: Minor
            Found in java/src/com/rubyeventmachine/EmReactor.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 run has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public void run() {
                    try {
                        mySelector = Selector.open();
                        bRunReactor = true;
                    } catch (IOException e) {
            Severity: Minor
            Found in java/src/com/rubyeventmachine/EmReactor.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

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

                public Object[] getPeerName (long sig) {
                    EventableChannel channel = Connections.get(sig);
                    if (channel != null) {
                        return Connections.get(sig).getPeerName();
                    }
            Severity: Major
            Found in java/src/com/rubyeventmachine/EmReactor.java and 1 other location - About 1 hr to fix
            java/src/com/rubyeventmachine/EmReactor.java on lines 553..563

            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

                public Object[] getSockName (long sig) {
                    EventableChannel channel = Connections.get(sig);
                    if (channel != null) {
                        return Connections.get(sig).getSockName();
                    }
            Severity: Major
            Found in java/src/com/rubyeventmachine/EmReactor.java and 1 other location - About 1 hr to fix
            java/src/com/rubyeventmachine/EmReactor.java on lines 541..551

            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

            There are no issues that match your filters.

            Category
            Status