koraktor/mavanagaiata

View on GitHub

Showing 68 of 68 total issues

File JGitRepository.java has 302 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/*
 * This code is free software; you can redistribute it and/or modify it under
 * the terms of the new BSD License.
 *
 * Copyright (c) 2012-2020, Sebastian Staudt

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

    public class JGitRepository extends AbstractGitRepository {
    
        static final String COMMONDIR_FILE = "commondir";
        static final Pattern DESCRIBE_PATTERN = Pattern.compile("(.*)-([1-9][0-9]*)-g([0-9a-f]+)$");
        static final String GITDIR_FILE = "gitdir";

      Method buildRepository has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
      Open

          final void buildRepository(File workTree, File gitDir) throws GitRepositoryException {
              if (gitDir == null && workTree == null) {
                  throw new GitRepositoryException("Neither worktree nor GIT_DIR is set.");
              } else {
                  if (workTree != null && !workTree.exists()) {

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

          void parseMailMap(File mailMap) throws IOException {
              try (BufferedReader mailMapReader = new BufferedReader(new FileReader(mailMap))) {
                  String line;
                  while ((line = mailMapReader.readLine()) != null) {
                      line = line.trim();
      Severity: Minor
      Found in src/main/java/com/github/koraktor/mavanagaiata/git/MailMap.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 parseMailMap has 31 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          void parseMailMap(File mailMap) throws IOException {
              try (BufferedReader mailMapReader = new BufferedReader(new FileReader(mailMap))) {
                  String line;
                  while ((line = mailMapReader.readLine()) != null) {
                      line = line.trim();
      Severity: Minor
      Found in src/main/java/com/github/koraktor/mavanagaiata/git/MailMap.java - About 1 hr to fix

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

            public void run(GitRepository repository) throws MavanagaiataMojoException {
                try {
                    GitCommit commit = repository.getHeadCommit();
                    String abbrevId  = repository.getAbbreviatedCommitId();
                    String shaId     = commit.getId();
        Severity: Minor
        Found in src/main/java/com/github/koraktor/mavanagaiata/mojo/CommitMojo.java - About 1 hr to fix

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

              @Override
              protected void writeOutput(GitRepository repository)
                      throws MavanagaiataMojoException {
                  try {
                      mailMap = repository.getMailMap();

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

                String getCanonicalMail(String name, String mail) {
                    if (mailToMailMap.containsKey(mail)) {
                        return mailToMailMap.get(mail);
                    }
            
            
            src/main/java/com/github/koraktor/mavanagaiata/git/MailMap.java on lines 112..127

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

            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

                String getCanonicalName(String name, String mail) {
                    if (mailToNameMap.containsKey(mail)) {
                        return mailToNameMap.get(mail);
                    }
            
            
            src/main/java/com/github/koraktor/mavanagaiata/git/MailMap.java on lines 88..103

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

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

                void printCompareLink(String currentRef, String lastRef, boolean isBranch) {
                    if (baseUrl == null) {
                        return;
                    }
            
            

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

                    protected void run() throws GitRepositoryException {
                        if (skipCommitsPattern != null && skipCommitsPattern.matcher(currentCommit.getMessage()).find()) {
                            return;
                        }
            
            

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

                private void resolveLinkedWorkTree(File workTree, File foundGitDir, FileRepositoryBuilder repositoryBuilder) throws IOException {
                    if (directoryContains(foundGitDir.getParentFile(), workTree)) {
                        repositoryBuilder.setGitDir(foundGitDir);
                        repositoryBuilder.setWorkTree(foundGitDir.getParentFile());
                    } else {

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

                @Override
                public GitTagDescription describe() throws GitRepositoryException {
                    DescribeCommand command = getDescribeCommand();
            
                    try {

              Method getValueSource has 26 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  MapBasedValueSource getValueSource(GitRepository repository)
                          throws GitRepositoryException {
                      GitTagDescription description = repository.describe();
              
                      String abbrevId  = repository.getAbbreviatedCommitId();

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

                    @Override
                    protected void initConfiguration() {
                        super.initConfiguration();
                
                        format = formatTemplate.getFormat().apply(format);
                Severity: Minor
                Found in src/main/java/com/github/koraktor/mavanagaiata/mojo/ChangelogMojo.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 writeOutput has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                Open

                    @Override
                    protected void writeOutput(GitRepository repository)
                            throws MavanagaiataMojoException {
                        try {
                            mailMap = repository.getMailMap();

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

                    @Override
                    public GitTagDescription describe() throws GitRepositoryException {
                        DescribeCommand command = getDescribeCommand();
                
                        try {

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

                    @Override
                    public Map<String, GitTag> getTags()
                            throws GitRepositoryException {
                        Map<String, GitTag> tags = new HashMap<>();
                
                

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

                    private void checkTag(GitRepository repository)
                            throws GitRepositoryException, CheckMojoException {
                        if (checkTag) {
                            if (!repository.describe().isTagged()) {
                                throw new CheckMojoException(CheckMojoException.Type.UNTAGGED);
                Severity: Minor
                Found in src/main/java/com/github/koraktor/mavanagaiata/mojo/CheckMojo.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

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

                    @Override
                    protected final void run(GitRepository repository) throws MavanagaiataMojoException {
                        if (getOutputFile() == null) {
                            printStream = System.out;
                            generateOutput(repository);

                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