wonderkiln/CameraKit-Android

View on GitHub

Showing 62 of 91 total issues

Method setFocusArea has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    void setFocusArea(float x, float y) {
        synchronized (mCameraLock) {
            if (mCamera != null) {
                Camera.Parameters parameters = getCameraParameters();
Severity: Major
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java - About 2 hrs to fix

Method findCommonAspectRatios has a Cognitive Complexity of 16 (exceeds 5 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 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 getCamcorderProfile has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private CamcorderProfile getCamcorderProfile(@VideoQuality int videoQuality) {
        CamcorderProfile camcorderProfile = null;
        switch (videoQuality) {
            case CameraKit.Constants.VIDEO_QUALITY_QVGA:
                if (CamcorderProfile.hasProfile(mCameraId, CamcorderProfile.QUALITY_QVGA)) {
Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java - About 1 hr to fix

Method adjustCameraParameters has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private void adjustCameraParameters(int currentTry) {
        boolean haveToReadjust = false;
        Camera.Parameters resolutionLess = mCamera.getParameters();

        if (getPreviewResolution() != null) {
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 getVideoResolution has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    Size getVideoResolution() {
        if (mVideoSize == null && mCameraParameters != null) {
            if (mCameraParameters.getSupportedVideoSizes() == null) {
                mVideoSize = getCaptureResolution();
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 process has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        private fun process(result: CaptureResult) {
            when (captureState) {
                STATE_PREVIEW -> {
                    val image = imageReader?.acquireLatestImage()
                    if (image != null) {
Severity: Minor
Found in camerakit/src/main/java/com/camerakit/api/camera2/Camera2.kt - About 1 hr to fix

Method getMissingPermissions has a Cognitive Complexity of 13 (exceeds 5 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

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 getCaptureResolution has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    Size getCaptureResolution() {
        if (mCaptureSize == null && mCameraParameters != null) {
            TreeSet<Size> sizes = new TreeSet<>();
            for (Camera.Size size : mCameraParameters.getSupportedPictureSizes()) {
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 run has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    @Override
    public void run() {
        Frame outputFrame;
        java.nio.ByteBuffer data;

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 onStart has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void onStart() {
        if (isInEditMode()) {
            return;
        }

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

Method prepareMediaRecorder has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private boolean prepareMediaRecorder(File videoFile, int maxDuration) throws IOException {
        synchronized (mCameraLock) {
            mCamera.unlock();

            mMediaRecorder = new MediaRecorder();
Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java - About 1 hr to fix

Method getCameraPreviewResolution has 37 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    Size getCameraPreviewResolution() {
        if (mPreviewSize == null && mCameraParameters != null) {
            TreeSet<Size> sizes = new TreeSet<>();
            for (Camera.Size size : mCameraParameters.getSupportedPreviewSizes()) {
                sizes.add(new Size(size.width, size.height));
Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java - About 1 hr to fix

Method run has 36 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    public void run() {
        Frame outputFrame;
        java.nio.ByteBuffer data;

Method onMeasure has a Cognitive Complexity of 12 (exceeds 5 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

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 onOrientationChanged has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
Open

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

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 setFocus has 35 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    @Override
    void setFocus(@Focus int focus) {
        synchronized (mCameraLock) {
            this.mFocus = focus;
            switch (focus) {
Severity: Minor
Found in camerakit/src/main/api16/com/wonderkiln/camerakit/Camera1.java - About 1 hr to fix

Method start has 32 lines of code (exceeds 25 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

Method startPreview has a Cognitive Complexity of 26 (exceeds 20 allowed). Consider refactoring.
Open

    private suspend fun startPreview(): Unit = suspendCoroutine {
        previewStartContinuation = it
        val surfaceTexture = surfaceTexture
        val attributes = attributes
        if (surfaceTexture != null && attributes != null) {
Severity: Minor
Found in camerakit/src/main/java/com/camerakit/CameraPreview.kt - 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 focus has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public void focus(float mx, float my) {
        mx *= getWidth();
        my *= getHeight();
        int x = (int) (mx - mFocusMarkerContainer.getWidth() / 2);
        int y = (int) (my - mFocusMarkerContainer.getWidth() / 2);

Method updateInfoText has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private void updateInfoText() {
        String facingValue = cameraView.getFacing() == CameraKit.FACING_BACK ? "BACK" : "FRONT";
        facingText.setText(Html.fromHtml("<b>Facing:</b> " + facingValue));

        String flashValue = "OFF";
Severity: Minor
Found in app/src/main/java/com/camerakit/app/MainActivity.java - About 1 hr to fix
Severity
Category
Status
Source
Language