TiagoMSSantos/MobileRT

View on GitHub
app/src/main/java/puscas/mobilertapp/MainRenderer.java

Summary

Maintainability
D
1 day
Test Coverage

File MainRenderer.java has 474 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package puscas.mobilertapp;

import android.app.ActivityManager;
import android.graphics.Bitmap;
import android.graphics.Color;
Severity: Minor
Found in app/src/main/java/puscas/mobilertapp/MainRenderer.java - About 7 hrs to fix

    MainRenderer has 40 methods (exceeds 20 allowed). Consider refactoring.
    Open

    public final class MainRenderer implements GLSurfaceView.Renderer {
    
        /**
         * Logger for this class.
         */
    Severity: Minor
    Found in app/src/main/java/puscas/mobilertapp/MainRenderer.java - About 5 hrs to fix

      Method onDrawFrame has 26 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          @Override
          public void onDrawFrame(@NonNull final GL10 gl) {
              logger.info("onDrawFrame");
      
              // Reset OpenGL frame buffer before drawing the new frame.
      Severity: Minor
      Found in app/src/main/java/puscas/mobilertapp/MainRenderer.java - About 1 hr to fix

        Use the built-in formatting to construct this argument.
        Open

                logger.info("resetStats numThreads: " + numThreads + ", numPrimitives: " + numPrimitives + ", numLights: " + numLights);

        Passing message arguments that require further evaluation into a Guava com.google.common.base.Preconditions check can result in a performance penalty. That's because whether or not they're needed, each argument must be resolved before the method is actually called.

        Similarly, passing concatenated strings into a logging method can also incur a needless performance hit because the concatenation will be performed every time the method is called, whether or not the log level is low enough to show the message.

        Instead, you should structure your code to pass static or pre-computed values into Preconditions conditions check and logging calls.

        Specifically, the built-in string formatting should be used instead of string concatenation, and if the message is the result of a method call, then Preconditions should be skipped altogether, and the relevant exception should be conditionally thrown instead.

        Noncompliant Code Example

        logger.log(Level.DEBUG, "Something went wrong: " + message);  // Noncompliant; string concatenation performed even when log level too high to show DEBUG messages
        
        logger.fine("An exception occurred with message: " + message); // Noncompliant
        
        LOG.error("Unable to open file " + csvPath, e);  // Noncompliant
        
        Preconditions.checkState(a > 0, "Arg must be positive, but got " + a);  // Noncompliant. String concatenation performed even when a > 0
        
        Preconditions.checkState(condition, formatMessage());  // Noncompliant. formatMessage() invoked regardless of condition
        
        Preconditions.checkState(condition, "message: %s", formatMessage());  // Noncompliant
        

        Compliant Solution

        logger.log(Level.SEVERE, "Something went wrong: {0} ", message);  // String formatting only applied if needed
        
        logger.fine("An exception occurred with message: {}", message);  // SLF4J, Log4j
        
        logger.log(Level.SEVERE, () -> "Something went wrong: " + message); // since Java 8, we can use Supplier , which will be evaluated lazily
        
        LOG.error("Unable to open file {0}", csvPath, e);
        
        if (LOG.isDebugEnabled() {
          LOG.debug("Unable to open file " + csvPath, e);  // this is compliant, because it will not evaluate if log level is above debug.
        }
        
        Preconditions.checkState(arg > 0, "Arg must be positive, but got %d", a);  // String formatting only applied if needed
        
        if (!condition) {
          throw new IllegalStateException(formatMessage());  // formatMessage() only invoked conditionally
        }
        
        if (!condition) {
          throw new IllegalStateException("message: " + formatMessage());
        }
        

        Exceptions

        catch blocks are ignored, because the performance penalty is unimportant on exceptional paths (catch block should not be a part of standard program flow). Getters are ignored as well as methods called on annotations which can be considered as getters. This rule accounts for explicit test-level testing with SLF4J methods isXXXEnabled and ignores the bodies of such if statements.

        Line is longer than 100 characters (found 131).
        Open

                setBitmap(ConfigResolution.Builder.Companion.create().build(), ConfigResolution.Builder.Companion.create().build(), false);

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 111).
        Open

                return renderSceneToBitmap(this.arrayVertices, this.arrayColors, this.arrayCamera, this.numPrimitives);

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 112).
        Open

                final ConfigGlAttribute.Builder builderVerticesAttribute = ConfigGlAttribute.Builder.Companion.create();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.nio.IntBuffer' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java.nio.IntBuffer;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Extra separation in import group before 'java8.util.Optional'
        Open

        import java8.util.Optional;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Extra separation in import group before 'javax.microedition.khronos.egl.EGLConfig'
        Open

        import javax.microedition.khronos.egl.EGLConfig;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line continuation have incorrect indentation level, expected level should be 4.
        Open

             * get the {@link State} of MobileRT.

        Checks the indentation of the continuation lines in block tags.That is whether thecontinued description of at clauses should be indented or not. If the text is not properlyindented it throws a violation. A continuation line is when the description starts/spanspast the line with the tag. Default indentation required is at least 4, but this can bechanged with the help of properties below.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 114).
        Open

                return (this.configResolutionView.getHeight() - line - 1) * this.configResolutionView.getWidth() + column;

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 135).
        Open

                    0, 0, configResolutionView.getWidth(), configResolutionView.getHeight(), GLES20.GL_RGBA, GLES20.GL_UNSIGNED_BYTE, intBuffer

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'javax.microedition.khronos.egl.EGLConfig' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import javax.microedition.khronos.egl.EGLConfig;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'kotlinx.coroutines.DelicateCoroutinesApi' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import kotlinx.coroutines.DelicateCoroutinesApi;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 128).
        Open

                logger.info("resetStats numThreads: " + numThreads + ", numPrimitives: " + numPrimitives + ", numLights: " + numLights);

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 111).
        Open

                final ConfigGlAttribute.Builder builderTextureAttribute = ConfigGlAttribute.Builder.Companion.create();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Extra separation in import group before 'java.lang.annotation.Native'
        Open

        import java.lang.annotation.Native;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 106).
        Open

            private final ConfigRenderTask.Builder configRenderTask = ConfigRenderTask.Builder.Companion.create();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 110).
        Open

                final ConfigGlAttribute.Builder builderColorsAttribute = ConfigGlAttribute.Builder.Companion.create();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 111).
        Open

                final ConfigGlAttribute.Builder builderTextureAttribute = ConfigGlAttribute.Builder.Companion.create();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.util.logging.Logger' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java.util.logging.Logger;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 101).
        Open

             * @implNote This method waits for the {@link #firstFrame} to be {@code false} so it can properly

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 104).
        Open

                        MainActivity.showUiMessage(ConstantsToast.COULD_NOT_RENDER_THE_SCENE + ex.getMessage());

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Extra separation in import group before 'com.google.common.base.Preconditions'
        Open

        import com.google.common.base.Preconditions;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.nio.ByteBuffer' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java.nio.ByteBuffer;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.lang.annotation.Native' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java.lang.annotation.Native;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'javax.microedition.khronos.opengles.GL10' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import javax.microedition.khronos.opengles.GL10;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 112).
        Open

                final ConfigGlAttribute.Builder builderVerticesAttribute = ConfigGlAttribute.Builder.Companion.create();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.nio.FloatBuffer' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java.nio.FloatBuffer;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 123).
        Open

                final String message = "MEMORY AVAILABLE: " + availMem + "MB (" + totalMem + "MB) [Needed " + memoryNeeded + "MB]";

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Extra separation in import group before 'org.jetbrains.annotations.Contract'
        Open

        import org.jetbrains.annotations.Contract;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 104).
        Open

            private ConfigResolution configResolutionView = ConfigResolution.Builder.Companion.create().build();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 112).
        Open

                final ConfigGlAttribute.Builder builderVerticesAttribute = ConfigGlAttribute.Builder.Companion.create();

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 126).
        Open

                this.bitmap = Bitmap.createBitmap(configResolution.getWidth(), configResolution.getHeight(), Bitmap.Config.ARGB_8888);

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Line is longer than 100 characters (found 123).
        Open

                    arrayBytesNewBitmap, configResolutionView.getWidth(), configResolutionView.getHeight(), Bitmap.Config.ARGB_8888

        Checks for long lines.

        Rationale: Long lines are hard to read in printouts or if developershave limited screen space for the source code, e.g. if the IDEdisplays additional information like project tree, class hierarchy,etc.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.util.Map' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java.util.Map;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Extra separation in import group before 'androidx.annotation.NonNull'
        Open

        import androidx.annotation.NonNull;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java.util.concurrent.TimeUnit' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java.util.concurrent.TimeUnit;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        Wrong lexicographical order for 'java8.util.Optional' import. Should be before 'org.jetbrains.annotations.Contract'.
        Open

        import java8.util.Optional;

        Checks that the groups of import declarations appear in the order specifiedby the user. If there is an import but its group is not specified in theconfiguration such an import should be placed at the end of the import list.

        This documentation is written and maintained by the Checkstyle community and is covered under the same license as the Checkstyle project.

        There are no issues that match your filters.

        Category
        Status