From b3eef9e92fd23174283cb58edeaae43f1d91446f Mon Sep 17 00:00:00 2001
From: "Jian-Syuan (Shane) Wong" <shanewong@google.com>
Date: Wed, 15 Jun 2022 21:13:47 +0000
Subject: [PATCH] Fix error-prone issues part1

---
 .../motion/utils/CustomSupport.java           |  6 +-
 .../motion/utils/ViewOscillator.java          |  1 +
 .../motion/utils/ViewSpline.java              |  1 +
 .../motion/utils/ViewTimeCycle.java           |  2 +
 .../constraintlayout/motion/widget/Key.java   |  1 +
 .../motion/widget/KeyAttributes.java          |  3 +
 .../motion/widget/KeyCycle.java               |  3 +
 .../motion/widget/KeyTimeCycle.java           |  3 +
 .../motion/widget/MotionInterpolator.java     |  1 +
 .../motion/widget/MotionLayout.java           | 28 +++---
 .../motion/widget/MotionScene.java            | 10 +--
 .../widget/ConstraintAttribute.java           | 11 ++-
 .../widget/ConstraintLayout.java              |  4 +-
 .../widget/ConstraintSet.java                 |  9 +-
 .../constraintlayout/core/ArrayRow.java       |  2 +
 .../constraintlayout/core/LinearSystem.java   |  2 +-
 .../core/motion/CustomAttribute.java          |  2 +-
 .../core/motion/CustomVariable.java           |  2 +-
 .../constraintlayout/core/motion/Motion.java  |  8 +-
 .../core/motion/MotionWidget.java             |  1 +
 .../core/motion/key/MotionKey.java            |  5 ++
 .../core/motion/key/MotionKeyTrigger.java     |  5 ++
 .../core/motion/utils/Easing.java             |  3 +
 .../core/motion/utils/KeyCycleOscillator.java | 87 -------------------
 .../core/motion/utils/SplineSet.java          |  7 ++
 .../constraintlayout/core/parser/CLArray.java |  2 +
 .../constraintlayout/core/parser/CLKey.java   |  2 +
 .../core/parser/CLObject.java                 |  4 +-
 .../core/state/WidgetFrame.java               |  2 -
 .../core/widgets/analyzer/WidgetGroup.java    |  2 +-
 30 files changed, 94 insertions(+), 125 deletions(-)

diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/CustomSupport.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/CustomSupport.java
index 6259c4509..7ee0ec6fe 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/CustomSupport.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/CustomSupport.java
@@ -29,7 +29,7 @@
 
 public class CustomSupport {
     private static final String TAG = "CustomSupport";
-
+    private static final boolean DEBUG = false;
     /**
      * sets the interpolated value
      * @param att
@@ -83,6 +83,10 @@ public static void setInterpolatedValue(ConstraintAttribute att, View view, floa
                     method = viewClass.getMethod(methodName, Float.TYPE);
                     method.invoke(view, value[0]);
                     break;
+                default:
+                    if (DEBUG) {
+                        Log.v(TAG, att.getType().toString());
+                    }
             }
         } catch (NoSuchMethodException e) {
             Log.e(TAG, "no method " + methodName + " on View \"" + Debug.getName(view) + "\"");
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewOscillator.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewOscillator.java
index 4fb6f735d..7e0a9b318 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewOscillator.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewOscillator.java
@@ -181,6 +181,7 @@ static class CustomSet extends ViewOscillator {
         float[] mValue = new float[1];
         protected ConstraintAttribute mCustom;
 
+        @Override
         protected void setCustom(Object custom) {
             mCustom = (ConstraintAttribute) custom;
         }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewSpline.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewSpline.java
index c7dc378d2..e6696936c 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewSpline.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewSpline.java
@@ -242,6 +242,7 @@ public void setup(int curveType) {
          * @param position the position
          * @param value the value
          */
+        @Override
         public void setPoint(int position, float value) {
             throw new RuntimeException("call of custom attribute setPoint");
         }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewTimeCycle.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewTimeCycle.java
index 8000ca8b4..f1d0b4d5d 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewTimeCycle.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/utils/ViewTimeCycle.java
@@ -272,6 +272,7 @@ public CustomSet(String attribute, SparseArray<ConstraintAttribute> attrList) {
          * Setup the curve
          * @param curveType
          */
+        @Override
         public void setup(int curveType) {
             int size = mConstraintAttributeList.size();
             int dimensionality =
@@ -303,6 +304,7 @@ public void setup(int curveType) {
          * @param shape
          * @param offset
          */
+        @Override
         public void setPoint(int position, float value, float period, int shape, float offset) {
             throw new RuntimeException("Wrong call for custom attribute");
         }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/Key.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/Key.java
index a65f4a7c9..60e5ba0b1 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/Key.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/Key.java
@@ -154,6 +154,7 @@ public Key copy(Key src) {
      * Return a copy of this
      * @return
      */
+    @Override
     public abstract Key clone();
 
     /**
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyAttributes.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyAttributes.java
index 2d776400a..7aaa8a778 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyAttributes.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyAttributes.java
@@ -138,6 +138,7 @@ public void getAttributeNames(HashSet<String> attributes) {
      * create the interpolations associated with this KeyAttribute
      * @param interpolation will be added to with keyAttributes
      */
+    @Override
     public void setInterpolation(HashMap<String, Integer> interpolation) {
         if (mCurveFit == -1) {
             return;
@@ -472,6 +473,7 @@ public static void read(KeyAttributes c, TypedArray a) {
      * @param src to be copied
      * @return self
      */
+    @Override
     public Key copy(Key src) {
         super.copy(src);
         KeyAttributes k = (KeyAttributes) src;
@@ -498,6 +500,7 @@ public Key copy(Key src) {
      * Clone this KeyAttributes
      * @return
      */
+    @Override
     public Key clone() {
         return new KeyAttributes().copy(this);
     }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyCycle.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyCycle.java
index 56d2c80a5..bb922a32c 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyCycle.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyCycle.java
@@ -85,6 +85,7 @@ public class KeyCycle extends Key {
      * @param context
      * @param attrs
      */
+    @Override
     public void load(Context context, AttributeSet attrs) {
         TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.KeyCycle);
         Loader.read(this, a);
@@ -491,6 +492,7 @@ public void setValue(String tag, Object value) {
      * @param src to be copied
      * @return self
      */
+    @Override
     public Key copy(Key src) {
         super.copy(src);
         KeyCycle k = (KeyCycle) src;
@@ -521,6 +523,7 @@ public Key copy(Key src) {
      * Clone this KeyAttributes
      * @return
      */
+    @Override
     public Key clone() {
         return new KeyCycle().copy(this);
     }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyTimeCycle.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyTimeCycle.java
index e31df1e0b..fb22db41b 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyTimeCycle.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/KeyTimeCycle.java
@@ -136,6 +136,7 @@ public void getAttributeNames(HashSet<String> attributes) {
      *
      * @param interpolation
      */
+    @Override
     public void setInterpolation(HashMap<String, Integer> interpolation) {
         if (mCurveFit == -1) {
             return;
@@ -357,6 +358,7 @@ public void setValue(String tag, Object value) {
      * @param src to be copied
      * @return self
      */
+    @Override
     public Key copy(Key src) {
         super.copy(src);
         KeyTimeCycle k = (KeyTimeCycle) src;
@@ -385,6 +387,7 @@ public Key copy(Key src) {
      *
      * @return
      */
+    @Override
     public Key clone() {
         return new KeyTimeCycle().copy(this);
     }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionInterpolator.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionInterpolator.java
index 75a9c4815..f638b47c6 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionInterpolator.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionInterpolator.java
@@ -28,6 +28,7 @@ public abstract class MotionInterpolator implements Interpolator {
      * @param v
      * @return
      */
+    @Override
     public abstract float getInterpolation(float v);
 
     /**
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java
index 6e79d946e..ed7e86b8e 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionLayout.java
@@ -1473,7 +1473,7 @@ protected void setTransition(MotionScene.Transition transition) {
             mTransitionGoalPosition = 0;
         }
         mTransitionLastTime =
-                (transition.isTransitionFlag(TRANSITION_FLAG_FIRST_DRAW)) ? -1 : getNanoTime();
+                transition.isTransitionFlag(TRANSITION_FLAG_FIRST_DRAW) ? -1 : getNanoTime();
         if (DEBUG) {
             Log.v(TAG, Debug.getLocation() + "  new mTransitionLastPosition = "
                     + mTransitionLastPosition + "");
@@ -1910,7 +1910,7 @@ private void setupMotionViews() {
                 }
                 float x = f.getFinalX();
                 float y = f.getFinalY();
-                float mdist = (flip) ? (y - x) : (y + x);
+                float mdist = flip ? (y - x) : (y + x);
                 min = Math.min(min, mdist);
                 max = Math.max(max, mdist);
             }
@@ -1944,9 +1944,9 @@ private void setupMotionViews() {
                     MotionController f = mFrameArrayList.get(getChildAt(i));
                     float x = f.getFinalX();
                     float y = f.getFinalY();
-                    float mdist = (flip) ? (y - x) : (y + x);
+                    float mdist = flip ? (y - x) : (y + x);
                     f.mStaggerScale = 1 / (1 - stagger);
-                    f.mStaggerOffset = stagger - stagger * (mdist - (min)) / (max - (min));
+                    f.mStaggerOffset = stagger - stagger * (mdist - min) / (max - min);
                 }
             }
         }
@@ -2519,7 +2519,7 @@ public void transitionToState(int id, int screenWidth, int screenHeight, int dur
                 float x = f.getFinalX();
                 float y = f.getFinalY();
                 f.mStaggerScale = 1 / (1 - stagger);
-                f.mStaggerOffset = stagger - stagger * (x + y - (min)) / (max - (min));
+                f.mStaggerOffset = stagger - stagger * (x + y - min) / (max - min);
             }
         }
 
@@ -2723,8 +2723,8 @@ private void setupConstraintWidget(ConstraintWidgetContainer base, ConstraintSet
                     if (view instanceof Barrier) {
                         ((Barrier) view).validateParams();
                         if (DEBUG) {
-                            Log.v(TAG, ">>>>>>>>>> Barrier " + (Debug.getName(getContext(),
-                                    ((Barrier) view).getReferencedIds())));
+                            Log.v(TAG, ">>>>>>>>>> Barrier " + Debug.getName(getContext(),
+                                    ((Barrier) view).getReferencedIds()));
                         }
                     }
                 }
@@ -3001,7 +3001,7 @@ private Rect toRect(ConstraintWidget cw) {
 
     @Override
     public void requestLayout() {
-        if (!(mMeasureDuringTransition)) {
+        if (!mMeasureDuringTransition) {
             if (mCurrentState == UNSET && mScene != null
                     && mScene.mCurrentTransition != null) {
                 int mode = mScene.mCurrentTransition.getLayoutDuringTransition();
@@ -3779,8 +3779,8 @@ void evaluate(boolean force) {
         }
 
         boolean newState = false;
-        if (mKeepAnimating || mInTransition
-                && (force || mTransitionGoalPosition != mTransitionLastPosition)) {
+        if (mKeepAnimating || (mInTransition
+                && (force || mTransitionGoalPosition != mTransitionLastPosition))) {
             float dir = Math.signum(mTransitionGoalPosition - mTransitionLastPosition);
             long currentTime = getNanoTime();
 
@@ -3818,7 +3818,7 @@ void evaluate(boolean force) {
                     position = mInterpolator.getInterpolation(time);
                     if (mInterpolator == mStopLogic) {
                         boolean dp = mStopLogic.isStopped();
-                        stopLogicDone = (dp) ? stopLogicStop : stopLogicContinue;
+                        stopLogicDone = dp ? stopLogicStop : stopLogicContinue;
                     }
 
                     if (DEBUG) {
@@ -4037,10 +4037,10 @@ private void init(AttributeSet attrs) {
                     apply = a.getBoolean(attr, apply);
                 } else if (attr == R.styleable.MotionLayout_showPaths) {
                     if (mDebugPath == 0) { // favor motionDebug
-                        mDebugPath = (a.getBoolean(attr, false)) ? DEBUG_SHOW_PATH : 0;
+                        mDebugPath = a.getBoolean(attr, false) ? DEBUG_SHOW_PATH : 0;
                     }
                 } else if (attr == R.styleable.MotionLayout_motionDebug) {
-                    mDebugPath = (a.getInt(attr, 0));
+                    mDebugPath = a.getInt(attr, 0);
                 }
             }
             a.recycle();
@@ -4281,7 +4281,7 @@ public boolean onInterceptTouchEvent(MotionEvent event) {
                 if (event.getAction() == MotionEvent.ACTION_DOWN) {
                     RectF region = touchResponse.getTouchRegion(this, new RectF());
                     if (region != null
-                            && (!region.contains(event.getX(), event.getY()))) {
+                            && !region.contains(event.getX(), event.getY())) {
                         return false;
                     }
                 }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java
index e65ad80e3..9c8bd66db 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/motion/widget/MotionScene.java
@@ -328,12 +328,12 @@ public Transition bestTransitionFor(int currentState,
                     transition.mTouchResponse.setRTL(mRtl);
                     RectF region = transition.mTouchResponse.getTouchRegion(mMotionLayout, cache);
                     if (region != null && lastTouchDown != null
-                            && (!region.contains(lastTouchDown.getX(), lastTouchDown.getY()))) {
+                            && !region.contains(lastTouchDown.getX(), lastTouchDown.getY())) {
                         continue;
                     }
                     region = transition.mTouchResponse.getLimitBoundsTo(mMotionLayout, cache);
                     if (region != null && lastTouchDown != null
-                            && (!region.contains(lastTouchDown.getX(), lastTouchDown.getY()))) {
+                            && !region.contains(lastTouchDown.getX(), lastTouchDown.getY())) {
                         continue;
                     }
 
@@ -1721,8 +1721,8 @@ void processTouchEvent(MotionEvent event, int currentState, MotionLayout motionL
                         region = mCurrentTransition.mTouchResponse
                                 .getTouchRegion(mMotionLayout, cache);
                         if (region != null
-                                && (!region.contains(mLastTouchDown.getX(),
-                                mLastTouchDown.getY()))) {
+                                && !region.contains(mLastTouchDown.getX(),
+                                mLastTouchDown.getY())) {
                             mMotionOutsideRegion = true;
                         } else {
                             mMotionOutsideRegion = false;
@@ -1742,7 +1742,7 @@ void processTouchEvent(MotionEvent event, int currentState, MotionLayout motionL
                     if (DEBUG) {
                         Log.v(TAG, "----- ACTION_MOVE " + dx + "," + dy);
                     }
-                    if (dx == 0.0 && dy == 0.0 || mLastTouchDown == null) {
+                    if ((dx == 0.0 && dy == 0.0) || mLastTouchDown == null) {
                         return;
                     }
 
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintAttribute.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintAttribute.java
index 5131e0b2f..f7108ca2d 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintAttribute.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintAttribute.java
@@ -39,6 +39,7 @@
  */
 public class ConstraintAttribute {
     private static final String TAG = "TransitionLayout";
+    private static final boolean DEBUG = false;
     private boolean mMethod = false;
     String mName;
     private AttributeType mType;
@@ -179,7 +180,7 @@ public void getValuesToInterpolate(float[] ret) {
                 int a = 0xFF & (mColorValue >> 24);
                 int r = 0xFF & (mColorValue >> 16);
                 int g = 0xFF & (mColorValue >> 8);
-                int b = 0xFF & (mColorValue);
+                int b = 0xFF & mColorValue;
                 float f_r = (float) Math.pow(r / 255.0f, 2.2);
                 float f_g = (float) Math.pow(g / 255.0f, 2.2);
                 float f_b = (float) Math.pow(b / 255.0f, 2.2);
@@ -196,6 +197,10 @@ public void getValuesToInterpolate(float[] ret) {
             case DIMENSION_TYPE:
                 ret[0] = mFloatValue;
                 break;
+            default:
+                if (DEBUG) {
+                    Log.v(TAG, mType.toString());
+                }
         }
     }
 
@@ -224,6 +229,10 @@ public void setValue(float[] value) {
                 break;
             case DIMENSION_TYPE:
                 mFloatValue = value[0];
+            default:
+                if (DEBUG) {
+                    Log.v(TAG, mType.toString());
+                }
 
         }
     }
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintLayout.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintLayout.java
index 05b16c271..dcd962818 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintLayout.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintLayout.java
@@ -801,8 +801,8 @@ public final void measure(ConstraintWidget widget,
                                 == BasicMeasure.Measure.USE_GIVEN_DIMENSIONS
                                             || !shouldDoWrap
                                             || (shouldDoWrap && otherDimensionStable)
-                                            || (child instanceof Placeholder)
-                                            || (widget.isResolvedHorizontally());
+                                            || child instanceof Placeholder
+                                            || widget.isResolvedHorizontally();
                         if (useCurrent) {
                             horizontalSpec = MeasureSpec.makeMeasureSpec(widget.getWidth(),
                                     MeasureSpec.EXACTLY);
diff --git a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java
index 42bddbd03..1197d6792 100644
--- a/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java
+++ b/constraintlayout/constraintlayout/src/main/java/androidx/constraintlayout/widget/ConstraintSet.java
@@ -2275,6 +2275,7 @@ private void setColorValue(String attributeName, int value) {
          * Return a copy of the Constraint
          * @return
          */
+        @Override
         public Constraint clone() {
             Constraint clone = new Constraint();
             clone.layout.copyFrom(layout);
@@ -6140,10 +6141,10 @@ String lookup(int id) {
                 if (id != -1) {
                     return mContext.getResources().getResourceEntryName(id);
                 } else {
-                    return "unknown" + (++mUnknownCount);
+                    return "unknown" + ++mUnknownCount;
                 }
             } catch (Exception ex) {
-                return "unknown" + (++mUnknownCount);
+                return "unknown" + ++mUnknownCount;
             }
         }
 
@@ -6391,10 +6392,10 @@ String lookup(int id) {
                 if (id != -1) {
                     return mContext.getResources().getResourceEntryName(id);
                 } else {
-                    return "unknown" + (++mUnknownCount);
+                    return "unknown" + ++mUnknownCount;
                 }
             } catch (Exception ex) {
-                return "unknown" + (++mUnknownCount);
+                return "unknown" + ++mUnknownCount;
             }
         }
 
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/ArrayRow.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/ArrayRow.java
index 5b0b1987a..40936be9f 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/ArrayRow.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/ArrayRow.java
@@ -135,6 +135,7 @@ boolean hasKeyVariable() {
     /**
      * @TODO: add description
      */
+    @Override
     public String toString() {
         return toReadableString();
     }
@@ -682,6 +683,7 @@ public void updateFromRow(LinearSystem system,
     /**
      * @TODO: add description
      */
+    @Override
     public void updateFromFinalVariable(LinearSystem system,
             SolverVariable variable,
             boolean removeFromDefinition) {
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/LinearSystem.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/LinearSystem.java
index 8a8947afd..4bab6426c 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/LinearSystem.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/LinearSystem.java
@@ -86,7 +86,7 @@ public class LinearSystem {
     public static Metrics sMetrics;
     private Row mTempGoal;
 
-    class ValuesRow extends ArrayRow {
+    static class ValuesRow extends ArrayRow {
         ValuesRow(Cache cache) {
             variables = new SolverVariableValues(this, cache);
         }
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomAttribute.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomAttribute.java
index 6734a88b5..099e8197f 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomAttribute.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomAttribute.java
@@ -150,7 +150,7 @@ public void getValuesToInterpolate(float[] ret) {
                 int a = 0xFF & (mColorValue >> 24);
                 int r = 0xFF & (mColorValue >> 16);
                 int g = 0xFF & (mColorValue >> 8);
-                int b = 0xFF & (mColorValue);
+                int b = 0xFF & mColorValue;
                 float f_r = (float) Math.pow(r / 255.0f, 2.2);
                 float f_g = (float) Math.pow(g / 255.0f, 2.2);
                 float f_b = (float) Math.pow(b / 255.0f, 2.2);
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomVariable.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomVariable.java
index bd731ad5c..b5cbca10a 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomVariable.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/CustomVariable.java
@@ -208,7 +208,7 @@ public void getValuesToInterpolate(float[] ret) {
                 int a = 0xFF & (mIntegerValue >> 24);
                 int r = 0xFF & (mIntegerValue >> 16);
                 int g = 0xFF & (mIntegerValue >> 8);
-                int b = 0xFF & (mIntegerValue);
+                int b = 0xFF & mIntegerValue;
                 float f_r = (float) Math.pow(r / 255.0f, 2.2);
                 float f_g = (float) Math.pow(g / 255.0f, 2.2);
                 float f_b = (float) Math.pow(b / 255.0f, 2.2);
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/Motion.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/Motion.java
index 43e6056f7..c2921c4d2 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/Motion.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/Motion.java
@@ -289,7 +289,7 @@ public void buildPath(float[] points, int pointCount) {
                 (mCycleMap == null) ? null : mCycleMap.get(MotionKey.TRANSLATION_Y);
 
         for (int i = 0; i < pointCount; i++) {
-            float position = (i) * mils;
+            float position = i * mils;
             if (mStaggerScale != 1.0f) {
                 if (position < mStaggerOffset) {
                     position = 0;
@@ -379,7 +379,7 @@ void buildBounds(float[] bounds, int pointCount) {
                 (mCycleMap == null) ? null : mCycleMap.get(MotionKey.TRANSLATION_Y);
 
         for (int i = 0; i < pointCount; i++) {
-            float position = (i) * mils;
+            float position = i * mils;
             if (mStaggerScale != 1.0f) {
                 if (position < mStaggerOffset) {
                     position = 0;
@@ -435,7 +435,7 @@ private float getPreCycleDistance() {
         float mils = 1.0f / (pointCount - 1);
         double x = 0, y = 0;
         for (int i = 0; i < pointCount; i++) {
-            float position = (i) * mils;
+            float position = i * mils;
 
             double p = position;
 
@@ -576,7 +576,7 @@ public void buildRect(float p, float[] path, int offset) {
     void buildRectangles(float[] path, int pointCount) {
         float mils = 1.0f / (pointCount - 1);
         for (int i = 0; i < pointCount; i++) {
-            float position = (i) * mils;
+            float position = i * mils;
             position = getAdjustedPosition(position, null);
             mSpline[0].getPos(position, mInterpolateData);
             mStartMotionPath.getRect(mInterpolateVariables, mInterpolateData, path, i * 8);
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/MotionWidget.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/MotionWidget.java
index a09ff4180..1cdd9072a 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/MotionWidget.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/MotionWidget.java
@@ -115,6 +115,7 @@ public void layout(int l, int t, int r, int b) {
     /**
      * @TODO: add description
      */
+    @Override
     public String toString() {
         return mWidgetFrame.left + ", " + mWidgetFrame.top + ", "
                 + mWidgetFrame.right + ", " + mWidgetFrame.bottom;
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKey.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKey.java
index 0a17a2c7f..0d5b3eff1 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKey.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKey.java
@@ -121,6 +121,7 @@ public MotionKey copy(MotionKey src) {
     /**
      * @TODO: add description
      */
+    @Override
     public abstract MotionKey clone();
 
     /**
@@ -148,6 +149,7 @@ public int getFramePosition() {
     /**
      * @TODO: add description
      */
+    @Override
     public boolean setValue(int type, int value) {
 
         switch (type) {
@@ -161,6 +163,7 @@ public boolean setValue(int type, int value) {
     /**
      * @TODO: add description
      */
+    @Override
     public boolean setValue(int type, float value) {
         return false;
     }
@@ -168,6 +171,7 @@ public boolean setValue(int type, float value) {
     /**
      * @TODO: add description
      */
+    @Override
     public boolean setValue(int type, String value) {
         switch (type) {
             case TypedValues.TYPE_TARGET:
@@ -180,6 +184,7 @@ public boolean setValue(int type, String value) {
     /**
      * @TODO: add description
      */
+    @Override
     public boolean setValue(int type, boolean value) {
         return false;
     }
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKeyTrigger.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKeyTrigger.java
index f926f13e2..f12421da6 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKeyTrigger.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/key/MotionKeyTrigger.java
@@ -122,6 +122,7 @@ public int getId(String name) {
     /**
      * @TODO: add description
      */
+    @Override
     public MotionKeyTrigger copy(MotionKey src) {
         super.copy(src);
         MotionKeyTrigger k = (MotionKeyTrigger) src;
@@ -148,6 +149,7 @@ public MotionKeyTrigger copy(MotionKey src) {
     /**
      * @TODO: add description
      */
+    @Override
     public MotionKey clone() {
         return new MotionKeyTrigger().copy(this);
     }
@@ -207,6 +209,7 @@ public boolean setValue(int type, int value) {
     /**
      * @TODO: add description
      */
+    @Override
     public boolean setValue(int type, float value) {
         switch (type) {
             case TriggerType.TYPE_TRIGGER_SLACK:
@@ -221,6 +224,7 @@ public boolean setValue(int type, float value) {
     /**
      * @TODO: add description
      */
+    @Override
     public boolean setValue(int type, String value) {
         switch (type) {
             case TriggerType.TYPE_CROSS:
@@ -247,6 +251,7 @@ public boolean setValue(int type, String value) {
     /**
      * @TODO: add description
      */
+    @Override
     public boolean setValue(int type, boolean value) {
         switch (type) {
             case TriggerType.TYPE_POST_LAYOUT:
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Easing.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Easing.java
index 1ebd651de..c97227ee2 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Easing.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/Easing.java
@@ -90,6 +90,7 @@ public double get(double x) {
     /**
      * @TODO: add description
      */
+    @Override
     public String toString() {
         return mStr;
     }
@@ -164,6 +165,7 @@ private double getDiffY(double t) {
          * binary search for the region
          * and linear interpolate the answer
          */
+        @Override
         public double getDiff(double x) {
             double t = 0.5;
             double range = 0.5;
@@ -189,6 +191,7 @@ public double getDiff(double x) {
          * binary search for the region
          * and linear interpolate the answer
          */
+        @Override
         public double get(double x) {
             if (x <= 0.0) {
                 return 0;
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/KeyCycleOscillator.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/KeyCycleOscillator.java
index 1a948cd65..77c617a09 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/KeyCycleOscillator.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/KeyCycleOscillator.java
@@ -228,93 +228,6 @@ public int compare(WavePoint lhs, WavePoint rhs) {
         mCurveFit = CurveFit.get(CurveFit.SPLINE, time, values);
     }
 
-    private static class IntDoubleSort {
-        static void sort(int[] key, float[] value, int low, int hi) {
-            int[] stack = new int[key.length + 10];
-            int count = 0;
-            stack[count++] = hi;
-            stack[count++] = low;
-            while (count > 0) {
-                low = stack[--count];
-                hi = stack[--count];
-                if (low < hi) {
-                    int p = partition(key, value, low, hi);
-                    stack[count++] = p - 1;
-                    stack[count++] = low;
-                    stack[count++] = hi;
-                    stack[count++] = p + 1;
-                }
-            }
-        }
-
-        private static int partition(int[] array, float[] value, int low, int hi) {
-            int pivot = array[hi];
-            int i = low;
-            for (int j = low; j < hi; j++) {
-                if (array[j] <= pivot) {
-                    swap(array, value, i, j);
-                    i++;
-                }
-            }
-            swap(array, value, i, hi);
-            return i;
-        }
-
-        private static void swap(int[] array, float[] value, int a, int b) {
-            int tmp = array[a];
-            array[a] = array[b];
-            array[b] = tmp;
-            float tmpv = value[a];
-            value[a] = value[b];
-            value[b] = tmpv;
-        }
-    }
-
-    private static class IntFloatFloatSort {
-        static void sort(int[] key, float[] value1, float[] value2, int low, int hi) {
-            int[] stack = new int[key.length + 10];
-            int count = 0;
-            stack[count++] = hi;
-            stack[count++] = low;
-            while (count > 0) {
-                low = stack[--count];
-                hi = stack[--count];
-                if (low < hi) {
-                    int p = partition(key, value1, value2, low, hi);
-                    stack[count++] = p - 1;
-                    stack[count++] = low;
-                    stack[count++] = hi;
-                    stack[count++] = p + 1;
-                }
-            }
-        }
-
-        private static int partition(int[] array, float[] value1, float[] value2, int low, int hi) {
-            int pivot = array[hi];
-            int i = low;
-            for (int j = low; j < hi; j++) {
-                if (array[j] <= pivot) {
-                    swap(array, value1, value2, i, j);
-                    i++;
-                }
-            }
-            swap(array, value1, value2, i, hi);
-            return i;
-        }
-
-        private static void swap(int[] array, float[] value1, float[] value2, int a, int b) {
-            int tmp = array[a];
-            array[a] = array[b];
-            array[b] = tmp;
-            float tmpFloat = value1[a];
-            value1[a] = value1[b];
-            value1[b] = tmpFloat;
-            tmpFloat = value2[a];
-            value2[a] = value2[b];
-            value2[b] = tmpFloat;
-        }
-    }
-
     static class CycleOscillator {
         static final int UNSET = -1; // -1 is typically used through out android to the UNSET value
         private static final String TAG = "CycleOscillator";
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/SplineSet.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/SplineSet.java
index 70348fe4e..5abac75eb 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/SplineSet.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/motion/utils/SplineSet.java
@@ -195,6 +195,7 @@ public static class CustomSet extends SplineSet {
         KeyFrameArray.CustomArray mConstraintAttributeList;
         float[] mTempValues;
 
+        @SuppressWarnings("StringSplitter")
         public CustomSet(String attribute, KeyFrameArray.CustomArray attrList) {
             mAttributeName = attribute.split(",")[1];
             mConstraintAttributeList = attrList;
@@ -227,6 +228,7 @@ public void setup(int curveType) {
         /**
          * @TODO: add description
          */
+        @Override
         public void setPoint(int position, float value) {
             throw new RuntimeException("don't call for custom "
                     + "attribute call setPoint(pos, ConstraintAttribute)");
@@ -258,6 +260,7 @@ private static class CoreSpline extends SplineSet {
             mStart = currentTime;
         }
 
+        @Override
         public void setProperty(TypedValues widget, float t) {
             int id = widget.getId(mType);
             widget.setValue(id, get(t));
@@ -269,6 +272,7 @@ public static class CustomSpline extends SplineSet {
         KeyFrameArray.CustomVar mConstraintAttributeList;
         float[] mTempValues;
 
+        @SuppressWarnings("StringSplitter")
         public CustomSpline(String attribute, KeyFrameArray.CustomVar attrList) {
             mAttributeName = attribute.split(",")[1];
             mConstraintAttributeList = attrList;
@@ -277,6 +281,7 @@ public CustomSpline(String attribute, KeyFrameArray.CustomVar attrList) {
         /**
          * @TODO: add description
          */
+        @Override
         public void setup(int curveType) {
             int size = mConstraintAttributeList.size();
             int dimensionality = mConstraintAttributeList.valueAt(0).numberOfInterpolatedValues();
@@ -301,6 +306,7 @@ public void setup(int curveType) {
         /**
          * @TODO: add description
          */
+        @Override
         public void setPoint(int position, float value) {
             throw new RuntimeException("don't call for custom attribute"
                     + " call setPoint(pos, ConstraintAttribute)");
@@ -309,6 +315,7 @@ public void setPoint(int position, float value) {
         /**
          * @TODO: add description
          */
+        @Override
         public void setProperty(TypedValues widget, float t) {
             setProperty((MotionWidget) widget, t);
         }
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLArray.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLArray.java
index 7837d731f..2ebd33dbd 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLArray.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLArray.java
@@ -27,6 +27,7 @@ public static CLElement allocate(char[] content) {
         return new CLArray(content);
     }
 
+    @Override
     protected String toJSON() {
         StringBuilder content = new StringBuilder(getDebugName() + "[");
         boolean first = true;
@@ -41,6 +42,7 @@ protected String toJSON() {
         return content + "]";
     }
 
+    @Override
     protected String toFormattedJSON(int indent, int forceIndent) {
         StringBuilder json = new StringBuilder();
         String val = toJSON();
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLKey.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLKey.java
index a3c2b83a2..41f13aef8 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLKey.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLKey.java
@@ -58,6 +58,7 @@ public String getName() {
         return content();
     }
 
+    @Override
     protected String toJSON() {
         if (mElements.size() > 0) {
             return getDebugName() + content() + ": " + mElements.get(0).toJSON();
@@ -65,6 +66,7 @@ protected String toJSON() {
         return getDebugName() + content() + ": <> ";
     }
 
+    @Override
     protected String toFormattedJSON(int indent, int forceIndent) {
         StringBuilder json = new StringBuilder(getDebugName());
         addIndent(json, indent);
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLObject.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLObject.java
index 364fb7181..5f8a1cd37 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLObject.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/parser/CLObject.java
@@ -33,6 +33,7 @@ public static CLObject allocate(char[] content) {
     /**
      * Returns objet as a JSON5 String
      */
+    @Override
     public String toJSON() {
         StringBuilder json = new StringBuilder(getDebugName() + "{ ");
         boolean first = true;
@@ -58,6 +59,7 @@ public String toFormattedJSON() {
     /**
      * Returns as a formatted JSON5 String with an indentation
      */
+    @Override
     public String toFormattedJSON(int indent, int forceIndent) {
         StringBuilder json = new StringBuilder(getDebugName());
         json.append("{\n");
@@ -81,7 +83,7 @@ public Iterator<CLKey> iterator() {
         return new CLObjectIterator(this);
     }
 
-    private class CLObjectIterator implements Iterator<CLKey> {
+    private static class CLObjectIterator implements Iterator<CLKey> {
         CLObject mObject;
         int mIndex = 0;
 
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/state/WidgetFrame.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/state/WidgetFrame.java
index cb5d1dc5f..62628c9bb 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/state/WidgetFrame.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/state/WidgetFrame.java
@@ -35,7 +35,6 @@
  * Utility class to encapsulate layout of a widget
  */
 public class WidgetFrame {
-    private static final boolean OLD_SYSTEM = true;
     public ConstraintWidget widget = null;
     public int left = 0;
     public int top = 0;
@@ -507,7 +506,6 @@ void parseCustom(CLElement custom) throws CLParsingException {
         for (int i = 0; i < n; i++) {
             CLElement tmp = obj.get(i);
             CLKey k = ((CLKey) tmp);
-            String name = k.content();
             CLElement v = k.getValue();
             String vStr = v.content();
             if (vStr.matches("#[0-9a-fA-F]+")) {
diff --git a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/WidgetGroup.java b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/WidgetGroup.java
index 2d31d01c3..df9e98b94 100644
--- a/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/WidgetGroup.java
+++ b/constraintlayout/core/src/main/java/androidx/constraintlayout/core/widgets/analyzer/WidgetGroup.java
@@ -261,7 +261,7 @@ public void cleanup(ArrayList<WidgetGroup> dependencyLists) {
     }
 
 
-    class MeasureResult {
+    static class MeasureResult {
         WeakReference<ConstraintWidget> mWidgetRef;
         int mLeft;
         int mTop;