zkbind/src/main/java/org/zkoss/bind/BindComposer.java

Summary

Maintainability
F
4 days
Test Coverage

File BindComposer.java has 506 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* BindComposer.java

    Purpose:
        
    Description:
Severity: Major
Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 1 day to fix

    Method initBinder has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
    Open

        private AnnotateBinder initBinder(BindEvaluatorX evalx, Component comp) {
            final ComponentCtrl compCtrl = (ComponentCtrl) comp;
            final Annotation idanno = compCtrl.getAnnotation(BINDER_ATTR, ID_ANNO);
            final Annotation initanno = compCtrl.getAnnotation(BINDER_ATTR, INIT_ANNO);
            Object binder = null;
    Severity: Minor
    Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 4 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

    BindComposer has 27 methods (exceeds 20 allowed). Consider refactoring.
    Open

    @SuppressWarnings("rawtypes")
    public class BindComposer<T extends Component>
            implements Composer<T>, ComposerExt<T>, Serializable, AuService, ComponentActivationListener {
    
        private static final long serialVersionUID = 1463169907348730644L;
    Severity: Minor
    Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 3 hrs to fix

      Method initBinder has 63 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private AnnotateBinder initBinder(BindEvaluatorX evalx, Component comp) {
              final ComponentCtrl compCtrl = (ComponentCtrl) comp;
              final Annotation idanno = compCtrl.getAnnotation(BINDER_ATTR, ID_ANNO);
              final Annotation initanno = compCtrl.getAnnotation(BINDER_ATTR, INIT_ANNO);
              Object binder = null;
      Severity: Major
      Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 2 hrs to fix

        Method service has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
        Open

            public boolean service(AuRequest request, boolean everError) {
                final String cmd = request.getCommand();
                if (cmd.startsWith(ON_BIND_COMMAND) || cmd.startsWith(ON_BIND_GLOBAL_COMMAND) || cmd.startsWith(ON_BIND_COMMAND_UPLOAD)) {
                    final Map<String, Object> data = request.getData();
                    String vcmd = data.get("cmd").toString();
        Severity: Minor
        Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.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 initViewModel has 50 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private Object initViewModel(BindEvaluatorX evalx, Component comp) {
                final ComponentCtrl compCtrl = (ComponentCtrl) comp;
                final Annotation idanno = compCtrl.getAnnotation(VIEW_MODEL_ATTR, ID_ANNO);
                final Annotation initanno = compCtrl.getAnnotation(VIEW_MODEL_ATTR, INIT_ANNO);
                String vmname = null;
        Severity: Minor
        Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 2 hrs to fix

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

              private ValidationMessages initValidationMessages(BindEvaluatorX evalx, Component comp, Binder binder) {
                  final ComponentCtrl compCtrl = (ComponentCtrl) comp;
                  final Annotation idanno = compCtrl.getAnnotation(VALIDATION_MESSAGES_ATTR, ID_ANNO);
                  final Annotation initanno = compCtrl.getAnnotation(VALIDATION_MESSAGES_ATTR, INIT_ANNO);
                  Object vmessages = null;
          Severity: Minor
          Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.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 doAfterCompose has 47 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void doAfterCompose(final T comp) throws Exception {
                  //ZK-3831
                  if (comp.getPage() == null) {
                      final Map<?, ?> currentArg = Executions.getCurrent().getArg();
                      ((ComponentCtrl) comp).addCallback(ComponentCtrl.AFTER_PAGE_ATTACHED, new Callback() {
          Severity: Minor
          Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 1 hr to fix

            Method initViewModel has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
            Open

                private Object initViewModel(BindEvaluatorX evalx, Component comp) {
                    final ComponentCtrl compCtrl = (ComponentCtrl) comp;
                    final Annotation idanno = compCtrl.getAnnotation(VIEW_MODEL_ATTR, ID_ANNO);
                    final Annotation initanno = compCtrl.getAnnotation(VIEW_MODEL_ATTR, INIT_ANNO);
                    String vmname = null;
            Severity: Minor
            Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.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 initValidationMessages has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private ValidationMessages initValidationMessages(BindEvaluatorX evalx, Component comp, Binder binder) {
                    final ComponentCtrl compCtrl = (ComponentCtrl) comp;
                    final Annotation idanno = compCtrl.getAnnotation(VALIDATION_MESSAGES_ATTR, ID_ANNO);
                    final Annotation initanno = compCtrl.getAnnotation(VALIDATION_MESSAGES_ATTR, INIT_ANNO);
                    Object vmessages = null;
            Severity: Minor
            Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 1 hr to fix

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

                  public void doBeforeComposeChildren(final Component comp) throws Exception {
                      //ZK-3831
                      if (comp.getPage() == null) {
                          final Map<?, ?> currentArg = Executions.getCurrent().getArg();
                          ((ComponentCtrl) comp).addCallback(ComponentCtrl.AFTER_PAGE_ATTACHED, new Callback() {
              Severity: Minor
              Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 1 hr to fix

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

                    public boolean service(AuRequest request, boolean everError) {
                        final String cmd = request.getCommand();
                        if (cmd.startsWith(ON_BIND_COMMAND) || cmd.startsWith(ON_BIND_GLOBAL_COMMAND) || cmd.startsWith(ON_BIND_COMMAND_UPLOAD)) {
                            final Map<String, Object> data = request.getData();
                            String vcmd = data.get("cmd").toString();
                Severity: Minor
                Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 1 hr to fix

                  Method getViewModelInitArgs has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private Map<String, Object> getViewModelInitArgs(BindEvaluatorX evalx, Component comp) {
                          final ComponentCtrl compCtrl = (ComponentCtrl) comp;
                          final Collection<Annotation> anncol = compCtrl.getAnnotations(VIEW_MODEL_ATTR, INIT_ANNO);
                          if (anncol.size() == 0)
                              return null;
                  Severity: Minor
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 55 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 doBeforeComposeChildren has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public void doBeforeComposeChildren(final Component comp) throws Exception {
                          //ZK-3831
                          if (comp.getPage() == null) {
                              final Map<?, ?> currentArg = Executions.getCurrent().getArg();
                              ((ComponentCtrl) comp).addCallback(ComponentCtrl.AFTER_PAGE_ATTACHED, new Callback() {
                  Severity: Minor
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java - About 25 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

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

                          if (comp.getPage() == null) {
                              final Map<?, ?> currentArg = Executions.getCurrent().getArg();
                              ((ComponentCtrl) comp).addCallback(ComponentCtrl.AFTER_PAGE_ATTACHED, new Callback() {
                                  public void call(Object data) {
                                      try {
                  Severity: Major
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java and 1 other location - About 1 hr to fix
                  zkbind/src/main/java/org/zkoss/bind/BindComposer.java on lines 170..185

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

                  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 (comp.getPage() == null) {
                              final Map<?, ?> currentArg = Executions.getCurrent().getArg();
                              ((ComponentCtrl) comp).addCallback(ComponentCtrl.AFTER_PAGE_ATTACHED, new Callback() {
                                  public void call(Object data) {
                                      try {
                  Severity: Major
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java and 1 other location - About 1 hr to fix
                  zkbind/src/main/java/org/zkoss/bind/BindComposer.java on lines 223..238

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

                  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 (name != null) {
                                  name = BindEvaluatorXUtil.eval(evalx, comp, expr = name, String.class);
                                  if (Strings.isBlank(name)) {
                                      throw new UiException(MiscUtil
                                              .formatLocationMessage("evaluated queue name is empty, expression is " + expr, initanno));
                  Severity: Minor
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java and 1 other location - About 50 mins to fix
                  zkbind/src/main/java/org/zkoss/bind/BindComposer.java on lines 399..405

                  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 (scope != null) {
                                  scope = BindEvaluatorXUtil.eval(evalx, comp, expr = scope, String.class);
                                  if (Strings.isBlank(scope)) {
                                      throw new UiException(MiscUtil
                                              .formatLocationMessage("evaluated queue scope is empty, expression is " + expr, initanno));
                  Severity: Minor
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java and 1 other location - About 50 mins to fix
                  zkbind/src/main/java/org/zkoss/bind/BindComposer.java on lines 392..398

                  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 (idanno != null) {
                              bname = BindEvaluatorXUtil.eval(evalx, comp,
                                      AnnotationUtil.testString(idanno.getAttributeValues(VALUE_ANNO_ATTR), idanno), String.class);
                              if (Strings.isEmpty(bname)) {
                                  throw new UiException(MiscUtil.formatLocationMessage("name of binder is empty", idanno));
                  Severity: Minor
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java and 1 other location - About 40 mins to fix
                  zkbind/src/main/java/org/zkoss/bind/BindComposer.java on lines 466..472

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

                  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 (idanno != null) {
                              vname = BindEvaluatorXUtil.eval(evalx, comp,
                                      AnnotationUtil.testString(idanno.getAttributeValues(VALUE_ANNO_ATTR), idanno), String.class);
                              if (Strings.isEmpty(vname)) {
                                  throw new UiException(MiscUtil.formatLocationMessage("name of ValidationMessages is empty", idanno));
                  Severity: Minor
                  Found in zkbind/src/main/java/org/zkoss/bind/BindComposer.java and 1 other location - About 40 mins to fix
                  zkbind/src/main/java/org/zkoss/bind/BindComposer.java on lines 376..382

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

                  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

                  There are no issues that match your filters.

                  Category
                  Status