zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java

Summary

Maintainability
F
5 days
Test Coverage

File DHtmlUpdateServlet.java has 489 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/* DHtmlUpdateServlet.java

    Purpose:
        
    Description:
Severity: Minor
Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 7 hrs to fix

    Method sessionTimeout has a Cognitive Complexity of 28 (exceeds 5 allowed). Consider refactoring.
    Open

        private void sessionTimeout(HttpServletRequest request, HttpServletResponse response, WebApp wapp, String dtid,
                boolean compress) throws ServletException, IOException {
            final String sid = request.getHeader("ZK-SID");
            if (sid != null) {
                //B65-ZK-2464 : Possible XSS Vulnerability in HTTP Header
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.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

    Method process has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
    Open

        public void process(Session sess, HttpServletRequest request, HttpServletResponse response, boolean compress)
                throws ServletException, IOException {
            final String errClient = request.getHeader("ZK-Error-Report");
            if (errClient != null)
                if (log.isDebugEnabled())
    Severity: Minor
    Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 3 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 process has 85 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public void process(Session sess, HttpServletRequest request, HttpServletResponse response, boolean compress)
                throws ServletException, IOException {
            final String errClient = request.getHeader("ZK-Error-Report");
            if (errClient != null)
                if (log.isDebugEnabled())
    Severity: Major
    Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 3 hrs to fix

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

      public class DHtmlUpdateServlet extends HttpServlet {
          private static final Logger log = LoggerFactory.getLogger(DHtmlUpdateServlet.class);
          private static final String ATTR_UPDATE_SERVLET = "org.zkoss.zk.au.http.updateServlet";
          private static final String ATTR_AU_PROCESSORS = "org.zkoss.zk.au.http.auProcessors";
      
      
      Severity: Minor
      Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 3 hrs to fix

        Method init has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
        Open

            public void init() throws ServletException {
                final ServletConfig config = getServletConfig();
                final ServletContext ctx = getServletContext();
                ctx.setAttribute(ATTR_UPDATE_SERVLET, this);
        
        
        Severity: Minor
        Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.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 doGet has 57 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected void doGet(HttpServletRequest request, HttpServletResponse response)
                    throws ServletException, IOException {
                final String pi = Https.getThisPathInfo(request);
                final ServletContext ctx = getServletContext();
                if (DHtmlResourceServlet.doGet0(request, response, ctx, getClassWebResource()))
        Severity: Major
        Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 2 hrs to fix

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

              protected void doGet(HttpServletRequest request, HttpServletResponse response)
                      throws ServletException, IOException {
                  final String pi = Https.getThisPathInfo(request);
                  final ServletContext ctx = getServletContext();
                  if (DHtmlResourceServlet.doGet0(request, response, ctx, getClassWebResource()))
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.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 init has 43 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public void init() throws ServletException {
                  final ServletConfig config = getServletConfig();
                  final ServletContext ctx = getServletContext();
                  ctx.setAttribute(ATTR_UPDATE_SERVLET, this);
          
          
          Severity: Minor
          Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 1 hr to fix

            Method sessionTimeout has 40 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private void sessionTimeout(HttpServletRequest request, HttpServletResponse response, WebApp wapp, String dtid,
                        boolean compress) throws ServletException, IOException {
                    final String sid = request.getHeader("ZK-SID");
                    if (sid != null) {
                        //B65-ZK-2464 : Possible XSS Vulnerability in HTTP Header
            Severity: Minor
            Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 1 hr to fix

              Method recoverDesktop has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected Desktop recoverDesktop(Session sess, HttpServletRequest request, HttpServletResponse response,
                          WebAppCtrl wappc, String dtid) {
                      final FailoverManager failover = wappc.getFailoverManager();
                      if (failover != null) {
                          Desktop desktop = null;
              Severity: Minor
              Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.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 getLastModified has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
              Open

                  protected long getLastModified(HttpServletRequest request) {
                      final String pi = Https.getThisPathInfo(request);
                      if (pi != null && pi.startsWith(ClassWebResource.PATH_PREFIX) && pi.indexOf('*') < 0 //language independent
                              && !Servlets.isIncluded(request)) {
                          //If a resource extension is registered for the extension,
              Severity: Minor
              Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 45 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 sessionTimeout has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  private void sessionTimeout(HttpServletRequest request, HttpServletResponse response, WebApp wapp, String dtid,
                          boolean compress) throws ServletException, IOException {
              Severity: Minor
              Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 35 mins to fix

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

                    protected Desktop recoverDesktop(Session sess, HttpServletRequest request, HttpServletResponse response,
                            WebAppCtrl wappc, String dtid) {
                Severity: Minor
                Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 35 mins to fix

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

                      public static final AuExtension getAuExtension(WebApp wapp, String prefix) {
                          DHtmlUpdateServlet upsv = DHtmlUpdateServlet.getUpdateServlet(wapp);
                          if (upsv == null) {
                              synchronized (DHtmlUpdateServlet.class) {
                                  upsv = DHtmlUpdateServlet.getUpdateServlet(wapp);
                  Severity: Minor
                  Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

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

                      public static final AuExtension addAuExtension(WebApp wapp, String prefix, AuExtension extension)
                              throws ServletException {
                          DHtmlUpdateServlet upsv = DHtmlUpdateServlet.getUpdateServlet(wapp);
                          if (upsv == null) {
                              synchronized (DHtmlUpdateServlet.class) {
                  Severity: Minor
                  Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 35 mins to fix

                  Cognitive Complexity

                  Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                  A method's cognitive complexity is based on a few simple rules:

                  • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                  • Code is considered more complex for each "break in the linear flow of the code"
                  • Code is considered more complex when "flow breaking structures are nested"

                  Further reading

                  Avoid too many return statements within this method.
                  Open

                                  return;
                  Severity: Major
                  Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 30 mins to fix

                    Avoid too many return statements within this method.
                    Open

                                return;
                    Severity: Major
                    Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java - About 30 mins to fix

                      Method isIgnorable has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                      Open

                              public boolean isIgnorable(Object request, WebApp wapp) {
                                  final HttpServletRequest hreq = (HttpServletRequest) request;
                                  for (int j = 0;; ++j) {
                                      if (hreq.getParameter("cmd_" + j) == null)
                                          break;
                      Severity: Minor
                      Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.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

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

                          protected long getLastModified(HttpServletRequest request) {
                              final String pi = Https.getThisPathInfo(request);
                              if (pi != null && pi.startsWith(ClassWebResource.PATH_PREFIX) && pi.indexOf('*') < 0 //language independent
                                      && !Servlets.isIncluded(request)) {
                                  //If a resource extension is registered for the extension,
                      zk/src/main/java/org/zkoss/zk/au/http/DHtmlResourceServlet.java on lines 61..75

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

                      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 (sid != null) {
                                  //B65-ZK-2464 : Possible XSS Vulnerability in HTTP Header
                                  try {
                                      Integer.parseInt(sid);
                                  } catch (NumberFormatException e) {
                      Severity: Minor
                      Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java and 1 other location - About 50 mins to fix
                      zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java on lines 478..488

                      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

                              if (sid != null) { //Some client might not have ZK-SID
                                  //B65-ZK-2464 : Possible XSS Vulnerability in HTTP Header
                                  try {
                                      Integer.parseInt(sid);
                                  } catch (NumberFormatException e) {
                      Severity: Minor
                      Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java and 1 other location - About 50 mins to fix
                      zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java on lines 557..567

                      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

                                  } finally {
                                      if (sess != null)
                                          I18Ns.cleanup(request, old);
                                      else {
                                          Charsets.cleanup(request, old);
                      Severity: Minor
                      Found in zk/src/main/java/org/zkoss/zk/au/http/DHtmlUpdateServlet.java and 1 other location - About 30 mins to fix
                      zk/src/main/java/org/zkoss/zk/au/http/DHtmlResourceServlet.java on lines 126..133

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

                      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