Showing 520 of 520 total issues
File MainActivity.java
has 624 lines of code (exceeds 250 allowed). Consider refactoring. Open
package puscas.mobilertapp;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.ActivityNotFoundException;
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;
MainRenderer
has 40 methods (exceeds 20 allowed). Consider refactoring. Open
public final class MainRenderer implements GLSurfaceView.Renderer {
/**
* Logger for this class.
*/
MainActivity
has 37 methods (exceeds 20 allowed). Consider refactoring. Open
public final class MainActivity extends Activity {
/**
* Logger for this class.
*/
Method onActivityResult
has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring. Open
@Override
protected void onActivityResult(final int requestCode,
final int resultCode,
@Nullable final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
- Read upRead up
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
File DrawView.java
has 251 lines of code (exceeds 250 allowed). Consider refactoring. Open
package puscas.mobilertapp;
import android.app.Activity;
import android.app.ActivityManager;
import android.content.Context;
Method onActivityResult
has 44 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
protected void onActivityResult(final int requestCode,
final int resultCode,
@Nullable final Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Method isPathReadable
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
private static boolean isPathReadable(final File file) {
final boolean readable = file.setReadable(true);
if (!file.canRead() && !readable) {
final File parentFile = file.getParentFile();
if (parentFile == null) {
- Read upRead up
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
package puscas.mobilertapp.constants;
import androidx.annotation.NonNull;
import java.util.logging.Logger;
- Read upRead up
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 95.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
package puscas.mobilertapp.constants;
import androidx.annotation.NonNull;
import java.util.logging.Logger;
- Read upRead up
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 95.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Method getPathFromFile
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
@NonNull
private String getPathFromFile(@NonNull final Uri uri) {
logger.info("Parsing path:" + Arrays.toString(uri.getPathSegments().toArray()));
validatePathIsAccessible(uri);
- Read upRead up
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 renderScene
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
synchronized void renderScene(@NonNull final Config config) {
logger.info(ConstantsMethods.RENDER_SCENE);
MainActivity.resetErrno();
stopDrawing();
Method perform
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
@Override
public void perform(@NonNull final UiController uiController, @NonNull final View view) {
final String methodName = Thread.currentThread().getStackTrace()[2].getMethodName();
logger.info(methodName);
Method setupRenderer
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void setupRenderer(final TextView textView, final Button renderButton) {
logger.info("setupRenderer start");
this.drawView.setVisibility(View.INVISIBLE);
this.drawView.setEGLContextClientVersion(MyEglContextFactory.EGL_CONTEXT_CLIENT_VERSION);
Method initializePickerResolutions
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void initializePickerResolutions(final int pickerSizes) {
logger.info("initializePickerResolutions start");
final int maxSizes = 9;
this.pickerResolutions.setMinValue(1);
this.pickerResolutions.setMaxValue(maxSizes - 1);
Method loadShader
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
@VisibleForTesting
public static int loadShader(final int shaderType,
@NonNull final String source) {
logger.info("loadShader");
final int shader = UtilsGL.run(() -> GLES20.glCreateShader(shaderType));
Method getPathFromFile
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
@NonNull
private String getPathFromFile(@NonNull final Uri uri) {
logger.info("Parsing path:" + Arrays.toString(uri.getPathSegments().toArray()));
validatePathIsAccessible(uri);
Method waitUntil
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static void waitUntil(@NonNull final MainActivity activity, final String expectedButtonText, final State... expectedStates) throws TimeoutException {
logger.info("waitUntil start, expected button: " + expectedButtonText + ", expected state(s): " + Arrays.toString(expectedStates));
final AtomicBoolean done = new AtomicBoolean(false);
/*
Only advance 1 second at a time, otherwise the following error can appear:
Method createConfigFromUI
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
@NonNull
private Config createConfigFromUI(@NonNull final String scenePath) {
final Pair<Integer, Integer> resolution =
Utils.getResolutionFromPicker(this.pickerResolutions);
Method readFile
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
private void readFile(@NonNull final Uri uri) {
logger.info("readFile");
final List<String> allowedPaths = List.of(Environment.getExternalStorageDirectory().getPath(), "/data/local/tmp/", "/storage/");
final boolean isAllowedPath;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {