HITGIF/TextFieldBoxes

View on GitHub

Showing 30 of 30 total issues

File TextFieldBoxes.java has 890 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package studio.carbonylgroup.textfieldboxes;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;

    TextFieldBoxes has 89 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @SuppressWarnings("unused")
    public class TextFieldBoxes extends FrameLayout {
    
        /**
         * all the default colors to be used on light or dark themes.

      Method updateCounterText has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
      Open

          protected void updateCounterText(boolean performValidation) {
      
              /* Show clear button if there is anything */
              if (hasClearButton) {
                  if (this.editText.getText().toString().length() == 0) {

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

          private void updateClearAndEndIconLayout() {
      
              if ((endIconImageButton != null && endIconImageButton.getDrawable() != null) || hasClearButton) {
      
                  int clearButtonW = hasClearButton ? clearButton.getMeasuredWidth() : 0;

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

          protected void updateDimens(boolean useDenseSpacing) {
      
              final Resources res = getContext().getResources();
      
              /* Floating Label */

        Method initOnClick has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private void initOnClick() {
        
                final FrameLayout mainBody = this;
        
                this.panel.setOnClickListener(new OnClickListener() {

          Method updateCounterText has 48 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              protected void updateCounterText(boolean performValidation) {
          
                  /* Show clear button if there is anything */
                  if (hasClearButton) {
                      if (this.editText.getText().toString().length() == 0) {

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

                @Override
                protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
            
                    int widthMode = MeasureSpec.getMode(widthMeasureSpec);
                    int heightMode = MeasureSpec.getMode(heightMeasureSpec);

              Method initViews has 41 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  private void initViews() {
              
                      this.editText = findEditTextChild();
                      if (editText == null) return;
                      this.addView(LayoutInflater.from(getContext()).inflate(rtl ?

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

                    protected void handleAttributes(Context context, AttributeSet attrs) {
                
                        try {
                
                            TypedArray styledAttrs = context.obtainStyledAttributes(attrs, R.styleable.TextFieldBoxes);

                  Method setEnabled has 27 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public void setEnabled(boolean enabled) {
                  
                          this.enabled = enabled;
                          if (this.enabled) {
                              this.editText.setEnabled(true);

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

                        private void updateClearAndEndIconLayout() {
                    
                            if ((endIconImageButton != null && endIconImageButton.getDrawable() != null) || hasClearButton) {
                    
                                int clearButtonW = hasClearButton ? clearButton.getMeasuredWidth() : 0;

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

                          protected void activate(boolean animated) {
                      
                              this.editText.setAlpha(1);
                      
                              if (this.editText.getText().toString().isEmpty() && !isActivated()) {

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                    if (this.alwaysShowHint && !this.editText.getHint().toString().isEmpty()) {
                        
                                        // If alwaysShowHint, and the hint is not empty,
                                        // keep the label on the top and EditText visible.
                                        this.editTextLayout.setAlpha(1f);
                        textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java on lines 611..618

                        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 58.

                        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

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                    if (this.minCharacters > 0) {
                                        /* MIN ONLY */
                                        this.counterLabel.setText(String.format(counterLabelResourceStr, lengthStr, Integer.toString(this.minCharacters), "+", ""));
                                        if (performValidation) {
                                            if (length < this.minCharacters) {
                        textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java on lines 804..814

                        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 58.

                        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

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                } else {
                        
                                    this.editTextLayout.setAlpha(1f);
                                    this.floatingLabel.setScaleX(0.75f);
                                    this.floatingLabel.setScaleY(0.75f);
                        textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java on lines 553..563

                        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 58.

                        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

                        Further Reading

                        Similar blocks of code found in 2 locations. Consider refactoring.
                        Open

                                    } else {
                                        /* MAX ONLY */
                                        this.counterLabel.setText(String.format(counterLabelResourceStr, lengthStr, Integer.toString(this.maxCharacters), "", ""));
                                        if (performValidation) {
                                            if (length > this.maxCharacters) {
                        textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java on lines 816..826

                        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 58.

                        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

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                                } else if (widthMode == MeasureSpec.AT_MOST) {
                        
                                    /* wrap_content */
                                    this.inputLayout.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
                                    this.upperPanel.getLayoutParams().width = ViewGroup.LayoutParams.WRAP_CONTENT;
                        textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java on lines 264..271

                        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 56.

                        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

                        Further Reading

                        Identical blocks of code found in 2 locations. Consider refactoring.
                        Open

                                if (widthMode == MeasureSpec.EXACTLY) {
                        
                                    /* match_parent or specific value */
                                    this.inputLayout.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
                                    this.upperPanel.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT;
                        textfieldboxes/src/main/java/studio/carbonylgroup/textfieldboxes/TextFieldBoxes.java on lines 271..277

                        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 56.

                        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

                        Further Reading

                        Method setEnabled has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                            public void setEnabled(boolean enabled) {
                        
                                this.enabled = enabled;
                                if (this.enabled) {
                                    this.editText.setEnabled(true);

                        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