Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aibolit cyclomatic fail to count for large lambda #642

Open
lyriccoder opened this issue Sep 16, 2020 · 0 comments
Open

Aibolit cyclomatic fail to count for large lambda #642

lyriccoder opened this issue Sep 16, 2020 · 0 comments

Comments

@lyriccoder
Copy link
Member

1.txt

Override
    @SuppressWarnings("aibolit.P31")
    public CompletableFuture<Void> save(final Key key, final Content content) {
        return CompletableFuture.supplyAsync(
            () -> {
                final Path tmp = Paths.get(
                    this.dir.toString(),
                    String.format("%s.%s.tmp", key.string(), UUID.randomUUID())
                );
                tmp.getParent().toFile().mkdirs();
                return tmp;
            },
            this.exec
        ).thenCompose(
            tmp -> new File(tmp).write(
                new OneTimePublisher<>(content),
                this.exec,
                StandardOpenOption.WRITE,
                StandardOpenOption.CREATE,
                StandardOpenOption.TRUNCATE_EXISTING
            ).thenCompose(
                nothing -> this.move(tmp, this.path(key))
            ).handleAsync(
                (nothing, throwable) -> {
                    tmp.toFile().delete();
                    final CompletableFuture<Void> result = new CompletableFuture<>();
                    if (throwable == null) {
                        result.complete(null);
                    } else {
                        result.completeExceptionally(throwable);
                    }
                    return result;
                },
                this.exec
            ).thenCompose(Function.identity())
        );
    }

Aibolit shows 0 Cogc for this method.
It also ignores all if/else statements inside lambda.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant