wonderkiln/CameraKit-Android

View on GitHub

Showing 62 of 91 total issues

Method getMissingPermissions has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private List<String> getMissingPermissions() {
        List<String> manifestPermissions = new ArrayList<>();

        if (Build.VERSION.SDK_INT < 23) {
            return manifestPermissions;
Severity: Minor
Found in camerakit/src/main/java/com/camerakit/CameraKitView.java - About 1 hr to fix

Method findCommonAspectRatios has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private TreeSet<AspectRatio> findCommonAspectRatios(List<Camera.Size> previewSizes, List<Camera.Size> pictureSizes) {
        Set<AspectRatio> previewAspectRatios = new HashSet<>();
        for (Camera.Size size : previewSizes) {
            AspectRatio deviceRatio = AspectRatio.of(CameraKit.Internal.screenHeight, CameraKit.Internal.screenWidth);
            AspectRatio previewRatio = AspectRatio.of(size.width, size.height);
Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java - About 1 hr to fix

Method onMeasure has 29 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mAdjustViewBounds) {
            ViewGroup.LayoutParams layoutParams = getLayoutParams();
            if (layoutParams.width == WRAP_CONTENT && layoutParams.height == WRAP_CONTENT) {
Severity: Minor
Found in camerakit/src/main/java/com/camerakit/CameraKitView.java - About 1 hr to fix

Method onLayoutChange has 9 arguments (exceeds 4 allowed). Consider refactoring.
Open

            public void onLayoutChange(View view, int i, int i1, int i2, int i3, int i4, int i5, int i6, int i7) {

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

        public void apply(JpegTransformer transformer) {
            switch (orientation) {
                case ExifInterface.ORIENTATION_FLIP_HORIZONTAL:
                    transformer.flipHorizontal();
                    break;

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

    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        if (mAdjustViewBounds) {
            Size previewSize = getPreviewSize();
            if (previewSize != null) {
Severity: Minor
Found in camerakit/src/main/java/com/wonderkiln/camerakit/CameraView.java - About 1 hr to fix

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

    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        if (requestCode == PERMISSION_REQUEST_CODE) {
            int approvedPermissions = 0;
            int deniedPermissions = 0;

Severity: Minor
Found in camerakit/src/main/java/com/camerakit/CameraKitView.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 start has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public void start() {
        if (mIsStarted || !isEnabled()) {
            // Already started, do nothing.
            return;
        }
Severity: Minor
Found in camerakit/src/main/java/com/wonderkiln/camerakit/CameraView.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 setFlash has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    void setFlash(@Flash int flash) {
        synchronized (mCameraLock) {
            if (mCameraParameters != null) {
                List<String> flashes = mCameraParameters.getSupportedFlashModes();
Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.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 onRequestPermissionsResult has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        if (requestCode == PERMISSION_REQUEST_CODE) {
            int approvedPermissions = 0;
            int deniedPermissions = 0;

Severity: Minor
Found in camerakit/src/main/java/com/camerakit/CameraKitView.java - About 1 hr to fix

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

    @Synchronized
    override fun open(facing: CameraFacing) {
        cameraFacing = facing
        val cameraId = cameraManager.getCameraId(facing) ?: throw RuntimeException()
        val cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId)
Severity: Minor
Found in camerakit/src/main/java/com/camerakit/api/camera2/Camera2.kt - About 1 hr to fix

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

            @Override
            public void onOrientationChanged(int orientation) {
                if (orientation == OrientationEventListener.ORIENTATION_UNKNOWN || mDisplay == null) {
                    return;
                }

Consider simplifying this complex logical expression.
Open

                if (parameters.getMaxNumFocusAreas() != 0 && focusMode != null &&
                        (focusMode.equals(Camera.Parameters.FOCUS_MODE_AUTO) ||
                                focusMode.equals(Camera.Parameters.FOCUS_MODE_MACRO) ||
                                focusMode.equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) ||
                                focusMode.equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_VIDEO))
Severity: Major
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java - About 40 mins to fix

Method onLayout has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    protected void onLayout(boolean changed, int l, int t, int r, int b) {

Method jniCropBitmap has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private native void jniCropBitmap(ByteBuffer handler, final int left, final int top, final int right, final int bottom);
Severity: Minor
Found in camerakit/src/main/utils/com/wonderkiln/camerakit/BitmapOperator.java - About 35 mins to fix

Method jniCrop has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

    private native void jniCrop(ByteBuffer handler, int left, int top, int width, int height);
Severity: Minor
Found in camerakit/src/main/utils/com/wonderkiln/camerakit/JpegTransformer.java - About 35 mins to fix

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

    private void requestPermissions(boolean requestCamera, boolean requestAudio) {
        Activity activity = null;
        Context context = getContext();
        while (context instanceof ContextWrapper) {
            if (context instanceof Activity) {
Severity: Minor
Found in camerakit/src/main/java/com/wonderkiln/camerakit/CameraView.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 setZoom has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    void setZoom(float zoomFactor) {
        synchronized (mCameraLock) {
            this.mZoom = zoomFactor;
            if (zoomFactor <= 1) {
Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.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 getZoomForPercent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    private int getZoomForPercent(int zoomPercent) {
        List<Integer> zoomRatios = mCameraParameters.getZoomRatios();
        int lowerIndex = -1;
        int upperIndex = -1;

Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.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 setPreviewSize has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public void setPreviewSize(Size previewSize, int displayOrientation) {
        if (mDisplayOrientation == 0 || mDisplayOrientation == 180) {
            this.mPreviewSize = previewSize;
        } else if ((displayOrientation == 90 || displayOrientation == 270) && (mDisplayOrientation != 90 && mDisplayOrientation != 270)) {
            this.mPreviewSize = new Size(previewSize.getHeight(), previewSize.getWidth());

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