configrd/configrd-service

View on GitHub

Showing 39 of 39 total issues

File GitConfigSource.java has 293 lines of code (exceeds 250 allowed). Consider refactoring.
Open

package io.configrd.core.git;

import java.io.Closeable;
import java.io.File;
import java.io.IOException;
Severity: Minor
Found in src/main/java/io/configrd/core/git/GitConfigSource.java - About 3 hrs to fix

    Method main has 73 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      public static void main(String[] args) throws Throwable {
    
        System.setProperty("org.jboss.logging.provider", "slf4j");
    
        Options options = new Options();
    Severity: Major
    Found in src/main/java/io/configrd/service/ConfigrdServer.java - About 2 hrs to fix

      GitRepoDef has 23 methods (exceeds 20 allowed). Consider refactoring.
      Open

      @SuppressWarnings("serial")
      public class GitRepoDef extends DefaultRepoDef
          implements SecuredRepo, FileBasedRepo, GitCredentials {
      
        public enum AuthMethod {
      Severity: Minor
      Found in src/main/java/io/configrd/core/git/GitRepoDef.java - About 2 hrs to fix

        Method start has 45 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

          protected void start(Map<String, Object> initParama) throws Throwable {
        
            if (GitStreamSource.GIT.equalsIgnoreCase((String) initParama.get(RepoDef.SOURCE_NAME_FIELD))
                && !initParama.containsKey(GitRepoDef.LOCAL_CLONE_FIELD)) {
              initParama.put(GitRepoDef.LOCAL_CLONE_FIELD, DEFAULT_LOCAL_CLONE);
        Severity: Minor
        Found in src/main/java/io/configrd/service/ConfigrdServer.java - About 1 hr to fix

          Method valid has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
          Open

            @Override
            public String[] valid() {
          
              List<String> err = new ArrayList<>();
          
          
          Severity: Minor
          Found in src/main/java/io/configrd/core/git/GitRepoDef.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 put has 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

            public boolean put(String path, PropertyPacket packet) {
          
              long start = System.currentTimeMillis();
              CannedAccessControlList acl = CannedAccessControlList.AuthenticatedRead;
          
          
          Severity: Minor
          Found in src/main/java/io/configrd/core/aws/s3/S3StreamSource.java - About 1 hr to fix

            Method gitPush has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

              private boolean gitPush(RevCommit commit) {
            
                boolean success = true;
            
                RefSpec spec = null;
            Severity: Minor
            Found in src/main/java/io/configrd/core/git/GitConfigSource.java - About 1 hr to fix

              Consider simplifying this complex logical expression.
              Open

                  if (StringUtils.hasText(getAuthMethod())
                      && (getAuthMethod().equals(AuthMethod.CodeCommitGitCreds.name())
                          || getAuthMethod().equals(AuthMethod.CodeCommitIAMUser.name())
                          || getAuthMethod().equals(AuthMethod.GitHub.name()))
                      && (!StringUtils.hasText(getUsername()) || getUsername().trim().startsWith("${")
              Severity: Critical
              Found in src/main/java/io/configrd/core/git/GitRepoDef.java - About 1 hr to fix

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

                  @Override
                  public String[] valid() {
                
                    List<String> err = new ArrayList<>();
                
                
                Severity: Minor
                Found in src/main/java/io/configrd/core/git/GitRepoDef.java - About 1 hr to fix

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

                    private void setupCredentials(String scheme, TransportCommand<? extends GitCommand, ?> command) {
                  
                      if (getStreamSource().getSourceConfig().getAuthMethod() != null
                          && (scheme == null || (!scheme.toLowerCase().startsWith("http")
                              && !scheme.toLowerCase().startsWith("git:")))) {
                  Severity: Minor
                  Found in src/main/java/io/configrd/core/git/GitConfigSource.java - About 1 hr to fix

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

                      private String write(PropertyPacket packet) {
                    
                        final URI uri = toURI(packet);
                    
                        String content = null;
                    Severity: Minor
                    Found in src/main/java/io/configrd/core/git/GitStreamSource.java - About 1 hr to fix

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

                        private boolean gitPush(RevCommit commit) {
                      
                          boolean success = true;
                      
                          RefSpec spec = null;
                      Severity: Minor
                      Found in src/main/java/io/configrd/core/git/GitConfigSource.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

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

                          try {
                            if (PropertiesProcessor.isPropertiesFile(uri.toString())) {
                              content = PropertiesProcessor.toText(packet);
                            } else if (YamlProcessor.isYamlFile(uri.toString())) {
                              content = new YAMLMapper().writeValueAsString(packet);
                      Severity: Major
                      Found in src/main/java/io/configrd/core/git/GitStreamSource.java and 1 other location - About 1 hr to fix
                      src/main/java/io/configrd/core/aws/s3/S3StreamSource.java on lines 107..115

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

                      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

                          try {
                            if (PropertiesProcessor.isPropertiesFile(repoDef.getFileName())) {
                              content = PropertiesProcessor.toText(packet);
                            } else if (YamlProcessor.isYamlFile(repoDef.getFileName())) {
                              content = new YAMLMapper().writeValueAsString(packet);
                      Severity: Major
                      Found in src/main/java/io/configrd/core/aws/s3/S3StreamSource.java and 1 other location - About 1 hr to fix
                      src/main/java/io/configrd/core/git/GitStreamSource.java on lines 87..95

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

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

                        @Override
                        public GitConfigSource newConfigSource(String name, Map<String, Object> values) {
                      
                          GitRepoDef def = new GitRepoDef(name, values);
                      
                      
                      Severity: Minor
                      Found in src/main/java/io/configrd/core/git/GitConfigSourceFactory.java - About 1 hr to fix

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

                          @Override
                          public GitConfigSource newConfigSource(String name, Map<String, Object> values) {
                        
                            GitRepoDef def = new GitRepoDef(name, values);
                        
                        
                        Severity: Minor
                        Found in src/main/java/io/configrd/core/git/GitConfigSourceFactory.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 init_repos has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          protected void init_repos(Map<String, Object> initParama) throws Exception {
                        
                            String path = (String) initParama.get(RepoDef.URI_FIELD);
                        
                            URI uri = URI.create(ConfigSourceResolver.DEFAULT_CONFIG_URI);
                        Severity: Minor
                        Found in src/main/java/io/configrd/service/ConfigrdServer.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 start has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          protected void start(Map<String, Object> initParama) throws Throwable {
                        
                            if (GitStreamSource.GIT.equalsIgnoreCase((String) initParama.get(RepoDef.SOURCE_NAME_FIELD))
                                && !initParama.containsKey(GitRepoDef.LOCAL_CLONE_FIELD)) {
                              initParama.put(GitRepoDef.LOCAL_CLONE_FIELD, DEFAULT_LOCAL_CLONE);
                        Severity: Minor
                        Found in src/main/java/io/configrd/service/ConfigrdServer.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 setupCredentials has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                        Open

                          private void setupCredentials(String scheme, TransportCommand<? extends GitCommand, ?> command) {
                        
                            if (getStreamSource().getSourceConfig().getAuthMethod() != null
                                && (scheme == null || (!scheme.toLowerCase().startsWith("http")
                                    && !scheme.toLowerCase().startsWith("git:")))) {
                        Severity: Minor
                        Found in src/main/java/io/configrd/core/git/GitConfigSource.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

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

                            try {
                        
                              if (packet.isPresent()) {
                                packet.get().putAll(
                                    ProcessorSelector.process(packet.get().getUri().toString(), packet.get().bytes()));
                        Severity: Minor
                        Found in src/main/java/io/configrd/core/git/GitStreamSource.java and 1 other location - About 40 mins to fix
                        src/main/java/io/configrd/core/aws/s3/S3StreamSource.java on lines 80..88

                        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

                        Severity
                        Category
                        Status
                        Source
                        Language