Jasig/WebproxyPortlet

View on GitHub

Showing 60 of 60 total issues

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

    @Override
    public void intercept(HttpContentRequestImpl proxyRequest,
            PortletRequest portletRequest) {
        
        // replace the portlet preference fields with user specific entries

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

    @RequestMapping
    public ModelAndView showContent(PortletRequest request) {
        final ModelAndView mv = new ModelAndView();
        
        final PortletPreferences preferences = request.getPreferences();

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

        @Override
        public boolean equals(Object obj) {
            if (this == obj)
                return true;
            if (obj == null)

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

        @Override
          public void intercept(HttpContentRequestImpl proxyRequest,
                  PortletRequest portletRequest) {
      
              try {

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

            @Override
            protected void prepareAuthentication(HttpContentRequestImpl contentRequest, PortletRequest portletRequest) {
        
                // retrieve the CAS ticket from the UserInfo map
                @SuppressWarnings("unchecked")

          Method validate has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
          Open

              @Override
              public boolean validate(HttpContentRequestImpl proxyRequest, PortletRequest portletRequest) {
                  boolean allPreferencesSet = true;
                  PortletPreferences prefs = portletRequest.getPreferences();
          
          

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

              @RequestMapping
              public ModelAndView showContent(PortletRequest request) {
                  final ModelAndView mv = new ModelAndView();
          
                  final PortletPreferences preferences = request.getPreferences();

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

                @Override
                public List<SearchResult> search(SearchRequest searchQuery,
                        EventRequest request, Document document) {
                    List<SearchResult> results = new ArrayList<SearchResult>();
                    final String[] whitelistRegexes = request.getPreferences().getValues("anchorWhitelistRegex", new String[] {});

              Avoid deeply nested control flow statements.
              Open

                                      if (!rslt.containsKey(preferenceName)) {
                                          // retrieve the preference and stuff the value here....
                                          String preferredValue = prefs.getValue(preferenceName, "");
                                          if (parameter.getSecured() && StringUtils.isNotBlank(preferredValue)
                                                  && stringEncryptionService != null) {

                Avoid deeply nested control flow statements.
                Open

                                        if (attributeUrl.contains("://") || attributeUrl.startsWith("//")) {
                                            // do nothing...
                                        }
                
                                        // (2) if the URL is relative to the server base,

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

                          public boolean getEnterCredentialsAllowed() {
                              // The way Gateway SSO supports user-provided credentials is by 
                              // piggy-backing on the UserPreferencesPreInterceptor, so the way 
                              // we'll answer this question (for now... until we learn why this 
                              // approach doesn't suit all circumstances) is by checking whether 

                  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 deeply nested control flow statements.
                  Open

                                          if (attributeUrl.toLowerCase().startsWith(p.getPrefix())) {
                                              ignorable = true;
                                          }

                    Method updateUrls has 6 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        protected void updateUrls(final Document document, final IContentResponse proxyResponse, final Map<String, Set<String>> elementSet,
                                final RenderRequest request, final RenderResponse response, boolean action) {

                      Avoid deeply nested control flow statements.
                      Open

                                              if (value != null) {
                                                  pairs.add(new BasicNameValuePair(param.getKey(), value));
                                              }

                        Avoid deeply nested control flow statements.
                        Open

                                                if (StringUtils.isNotBlank(regex)) {
                                                  final Pattern pattern = Pattern.compile(regex);  // TODO share compiled regexes
                                                  if (pattern.matcher(attributeUrl).find()) {
                        
                                                      // record that we've rewritten this URL

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

                                  synchronized (PortletUtils.getSessionMutex(session)) {
                                      rewrittenUrls = (ConcurrentMap<String, String>) session
                                              .getAttribute(REWRITTEN_URLS_KEY);
                          
                                      // if the rewritten URLs list doesn't exist yet, create it
                          src/main/java/org/jasig/portlet/proxy/service/proxy/document/URLRewritingFilter.java on lines 137..145

                          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

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

                                  synchronized (PortletUtils.getSessionMutex(session)) {
                                      rewrittenUrls = (ConcurrentMap<String, String>) session.getAttribute(REWRITTEN_URLS_KEY);
                          
                                      // if the rewritten URLs list doesn't exist yet, create it
                                      if (rewrittenUrls == null) {
                          src/main/java/org/jasig/portlet/proxy/search/util/SearchUtil.java on lines 56..65

                          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

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

                                  if (mobileXslt != null) {
                                      final boolean isMobile = viewSelector.isMobile(request);
                                      xslt = isMobile ? mobileXslt : mainXslt;
                                  } else {
                                      xslt = mainXslt;
                          src/main/java/org/jasig/portlet/proxy/mvc/portlet/json/JsonPortletController.java on lines 128..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 46.

                          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 (mobileView != null) {
                                      final boolean isMobile = viewSelector.isMobile(request);
                                      viewName = isMobile ? mobileView : mainView;
                                  } else {
                                      viewName = mainView;
                          src/main/java/org/jasig/portlet/proxy/mvc/portlet/xslt/XsltPortletController.java on lines 113..118

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

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

                              @RenderMapping
                              public ModelAndView getView(RenderRequest request){
                                  final ModelAndView mv = new ModelAndView();
                                  final List<GatewayEntry> entries =  removeInaccessibleEntries(gatewayEntries, request);
                                  final Map<String, Boolean> validations = new HashMap<String, Boolean>();

                          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