laudis-technologies/neo4j-php-client

View on GitHub

Showing 35 of 35 total issues

Function retry has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

    public static function retry(callable $tsxFactory, callable $tsxHandler)
    {
        while (true) {
            $transaction = null;
            try {
Severity: Minor
Found in src/Common/TransactionHelper.php - 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 __construct has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function __construct($iterable = [])
    {
        if (is_array($iterable)) {
            $i = 0;
            foreach ($iterable as $key => $value) {
Severity: Minor
Found in src/Types/Map.php - About 1 hr to fix

Consider simplifying this complex logical expression.
Open

                if (((is_array($value) && array_key_exists($key, $value)) || ($value instanceof ArrayAccess && $value->offsetExists($key))) && $this->isStringable($value[$key])) {
                    yield $value[$key] => $value;
                } elseif (is_object($value) && property_exists($value, $key) && $this->isStringable($value->$key)) {
                    yield $value->$key => $value;
                } else {
Severity: Major
Found in src/Types/AbstractCypherSequence.php - About 1 hr to fix

Function translateString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function translateString(string $value, HttpMetaInfo $meta): array
    {
        switch ($meta->getCurrentType()) {
            case 'duration':
                $meta = $meta->incrementMeta();
Severity: Minor
Found in src/Formatter/Specialised/LegacyHttpOGMTranslator.php - 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

Function pluck has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function pluck(string $key): ArrayList
    {
        return new ArrayList(function () use ($key) {
            foreach ($this as $value) {
                if ((is_array($value) && array_key_exists($key, $value)) || ($value instanceof ArrayAccess && $value->offsetExists($key))) {
Severity: Minor
Found in src/Types/AbstractCypherSequence.php - 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

Function keyBy has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function keyBy(string $key): Map
    {
        return new Map(function () use ($key) {
            foreach ($this as $value) {
                if (((is_array($value) && array_key_exists($key, $value)) || ($value instanceof ArrayAccess && $value->offsetExists($key))) && $this->isStringable($value[$key])) {
Severity: Minor
Found in src/Types/AbstractCypherSequence.php - 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

Function convertTemporalTypes has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    private static function convertTemporalTypes(mixed $value, ConnectionProtocol $protocol): ?IStructure
    {
        if ($protocol->isBolt()) {
            if ($value instanceof DateTimeInterface) {
                if ($protocol->compare(ConnectionProtocol::BOLT_V44()) > 0) {
Severity: Minor
Found in src/ParameterHelper.php - 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

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

    private static function createNeo4jDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, FormatterInterface $formatter = null): DriverInterface
    {
        if ($formatter !== null) {
            return Neo4jDriver::create($uri, $configuration, $authenticate, $formatter);
        }
Severity: Major
Found in src/DriverFactory.php and 2 other locations - About 40 mins to fix
src/DriverFactory.php on lines 79..86
src/DriverFactory.php on lines 121..128

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

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

    private static function createBoltDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, FormatterInterface $formatter = null): DriverInterface
    {
        if ($formatter !== null) {
            return BoltDriver::create($uri, $configuration, $authenticate, $formatter);
        }
Severity: Major
Found in src/DriverFactory.php and 2 other locations - About 40 mins to fix
src/DriverFactory.php on lines 99..106
src/DriverFactory.php on lines 121..128

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

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

    private static function createHttpDriver(string|UriInterface $uri, ?DriverConfiguration $configuration, ?AuthenticateInterface $authenticate, FormatterInterface $formatter = null): DriverInterface
    {
        if ($formatter !== null) {
            return HttpDriver::create($uri, $configuration, $authenticate, $formatter);
        }
Severity: Major
Found in src/DriverFactory.php and 2 other locations - About 40 mins to fix
src/DriverFactory.php on lines 79..86
src/DriverFactory.php on lines 99..106

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

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

Function getDriver has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getDriver(SessionConfiguration $config, ?string $alias = null): DriverInterface
    {
        $alias ??= $this->decideAlias($alias);

        if (!array_key_exists($alias, $this->driverSetups)) {
Severity: Minor
Found in src/Common/DriverSetupManager.php - About 35 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

Avoid too many return statements within this method.
Open

            return $this->translateString($value, $meta);
Severity: Major
Found in src/Formatter/Specialised/LegacyHttpOGMTranslator.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

        return [$value, $meta->incrementMeta()];
Severity: Major
Found in src/Formatter/Specialised/LegacyHttpOGMTranslator.php - About 30 mins to fix

Function next has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function next(): void
    {
        $generator = $this->getGenerator();
        if ($this->cache === []) {
            $this->setupCache();
Severity: Minor
Found in src/Types/AbstractCypherSequence.php - 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

Function translateObject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    private function translateObject(stdClass $value, HttpMetaInfo $meta): array
    {
        $type = $meta->getCurrentType();
        if ($type === 'relationship') {
            /** @var stdClass $relationship */
Severity: Minor
Found in src/Formatter/Specialised/LegacyHttpOGMTranslator.php - 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

Severity
Category
Status
Source
Language