CloudSlang/cs-actions

View on GitHub
cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailAttachmentService.java

Summary

Maintainability
F
3 days
Test Coverage

Method downloadAttachment has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring.
Open

    private String downloadAttachment(Message message, String attachment, String characterSet, String path, boolean overwrite) throws Exception {
        if (!message.isMimeType(MimeTypes.TEXT_PLAIN) && !message.isMimeType(MimeTypes.TEXT_HTML)) {

            Multipart mpart = (Multipart) message.getContent();
            File f = new File(path);

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

    private String readAttachment(Message message, String attachment, String characterSet) throws Exception {
        if (!message.isMimeType(MimeTypes.TEXT_PLAIN) && !message.isMimeType(MimeTypes.TEXT_HTML)) {

            Multipart mpart = (Multipart) message.getContent();

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

    private MimeBodyPart decryptPart(MimeBodyPart part) throws Exception {

        SMIMEEnveloped m = new SMIMEEnveloped(part);

        RecipientInformationStore recipients = m.getRecipientInfos();

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

    public Map<String, String> execute(GetMailAttachmentInput getMailAttachmentInput) throws Exception {
        this.results = new HashMap<>();
        this.input = getMailAttachmentInput;

        try (Store store = SSLUtils.createMessageStore(input);

    Method downloadAttachment has 33 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private String downloadAttachment(Message message, String attachment, String characterSet, String path, boolean overwrite) throws Exception {
            if (!message.isMimeType(MimeTypes.TEXT_PLAIN) && !message.isMimeType(MimeTypes.TEXT_HTML)) {
    
                Multipart mpart = (Multipart) message.getContent();
                File f = new File(path);

      Method decryptPart has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private MimeBodyPart decryptPart(MimeBodyPart part) throws Exception {
      
              SMIMEEnveloped m = new SMIMEEnveloped(part);
      
              RecipientInformationStore recipients = m.getRecipientInfos();

        Method readAttachment has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private String readAttachment(Message message, String attachment, String characterSet) throws Exception {
                if (!message.isMimeType(MimeTypes.TEXT_PLAIN) && !message.isMimeType(MimeTypes.TEXT_HTML)) {
        
                    Multipart mpart = (Multipart) message.getContent();
        
        

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

              public Map<String, String> execute(GetMailAttachmentInput getMailAttachmentInput) throws Exception {
                  this.results = new HashMap<>();
                  this.input = getMailAttachmentInput;
          
                  try (Store store = SSLUtils.createMessageStore(input);

          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 (input.isEncryptedMessage() && part.getContentType() != null &&
                                          part.getContentType().matches(SecurityConstants.ENCRYPTED_CONTENT_TYPE)) {
                                      part = decryptPart((MimeBodyPart) part);
                                  }

            Avoid deeply nested control flow statements.
            Open

                                    if (disposition != null && disposition.equalsIgnoreCase(Part.ATTACHMENT)) {
                                        String partPrefix = part.getContentType().toLowerCase();
                                        if (partPrefix.startsWith(MimeTypes.TEXT_PLAIN)) {
                                            String attachmentContent = attachmentToString(part, characterSet);
                                            results.put(io.cloudslang.content.constants.OutputNames.RETURN_RESULT, MimeUtility.decodeText(attachmentContent));

              Avoid deeply nested control flow statements.
              Open

                                      if (part != null && part.getFileName() != null &&
                                              (MimeUtility.decodeText(part.getFileName()).equalsIgnoreCase(attachment) ||
                                                      part.getFileName().equalsIgnoreCase(attachment))
                                      ) {
                                          String disposition = part.getDisposition();

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

                    private String downloadAttachment(Message message, String attachment, String characterSet, String path, boolean overwrite) throws Exception {

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

                              if (input.isEncryptedMessage()) {
                                  if (Security.getProvider(SecurityConstants.BOUNCY_CASTLE_PROVIDER) == null) {
                                      Security.addProvider(new BouncyCastleProvider());
                                  }
                                  ks = KeyStore.getInstance(SecurityConstants.PKCS_KEYSTORE_TYPE, SecurityConstants.BOUNCY_CASTLE_PROVIDER);
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 58..64

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

                  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

                              for (Object rec : recipients.getRecipients()) {
                                  if (rec instanceof RecipientInformation) {
                                      RecipientId recipientId = ((RecipientInformation) rec).getRID();
                                      errorMessage.append("\"" + recipientId.toString() + "\"\n");
                                  }
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 330..335

                  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 5 locations. Consider refactoring.
                  Open

                                      if (input.isEncryptedMessage() && part.getContentType() != null &&
                                              part.getContentType().matches(SecurityConstants.ENCRYPTED_CONTENT_TYPE)) {
                                          part = decryptPart((MimeBodyPart) part);
                                      }
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailAttachmentService.java on lines 233..236
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 188..191
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 245..248
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 349..352

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

                  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 5 locations. Consider refactoring.
                  Open

                                          if (input.isEncryptedMessage() && part.getContentType() != null &&
                                                  part.getContentType().matches(SecurityConstants.ENCRYPTED_CONTENT_TYPE)) {
                                              part = decryptPart((MimeBodyPart) part);
                                          }
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailAttachmentService.java on lines 109..112
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 188..191
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 245..248
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailMessageService.java on lines 349..352

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

                  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 (part != null && part.getFileName() != null &&
                                              (MimeUtility.decodeText(part.getFileName()).equalsIgnoreCase(attachment) ||
                                                      part.getFileName().equalsIgnoreCase(attachment))
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailAttachmentService.java on lines 238..240

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

                  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 (part != null && part.getFileName() != null &&
                                                  (MimeUtility.decodeText(part.getFileName()).equalsIgnoreCase(attachment) ||
                                                          part.getFileName().equalsIgnoreCase(attachment))
                  cs-mail/src/main/java/io/cloudslang/content/mail/services/GetMailAttachmentService.java on lines 114..116

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

                  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 (input.getMessageNumber() > folder.getMessageCount()) {
                                  throw new IndexOutOfBoundsException("Message value was: " + input.getMessageNumber() + " there are only " +
                                          folder.getMessageCount() + " messages in folder");
                              }
                  cs-abbyy/src/test/java/io/cloudslang/content/abbyy/services/ProcessImageServiceTest.java on lines 236..266

                  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