ekinhbayar/gitamp

View on GitHub

Showing 27 of 27 total issues

Function GitAmp has 400 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const GitAmp = (function(exports, $) {
    'use strict';

    /**
     * AudioPlayer
Severity: Major
Found in public/js/main.js - About 2 days to fix

    Function GitAmp has a Cognitive Complexity of 65 (exceeds 5 allowed). Consider refactoring.
    Open

    const GitAmp = (function(exports, $) {
        'use strict';
    
        /**
         * AudioPlayer
    Severity: Minor
    Found in public/js/main.js - About 1 day 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

    <?php declare(strict_types=1);
    
    namespace ekinhbayar\GitAmp\Event\GitHub;
    
    use ekinhbayar\GitAmp\Event\BaseEvent;
    Severity: Major
    Found in src/Event/GitHub/WatchEvent.php and 1 other location - About 7 hrs to fix
    src/Event/GitHub/ForkEvent.php on lines 1..66

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

    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

    <?php declare(strict_types=1);
    
    namespace ekinhbayar\GitAmp\Event\GitHub;
    
    use ekinhbayar\GitAmp\Event\BaseEvent;
    Severity: Major
    Found in src/Event/GitHub/ForkEvent.php and 1 other location - About 7 hrs to fix
    src/Event/GitHub/WatchEvent.php on lines 1..66

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

    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

    File main.js has 406 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    const GitAmp = (function(exports, $) {
        'use strict';
    
        /**
         * AudioPlayer
    Severity: Minor
    Found in public/js/main.js - About 5 hrs to fix

      Function Gui has 119 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          const Gui = (function() {
              const scaleFactor = 6;
              const textColor   = '#ffffff';
              const maxLife     = 20000;
      
      
      Severity: Major
      Found in public/js/main.js - About 4 hrs to fix

        Function AudioPlayer has 111 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            const AudioPlayer = (function() {
                // something somewhere needs a global volume variable
                // not sure what thing it is, but adding this line works
                exports.volume = localStorage.getItem('volume');
        
        
        Severity: Major
        Found in public/js/main.js - About 4 hrs to fix

          Function draw has 53 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

                  Event.prototype.draw = function(width, height) {
                      let no_label = false;
                      let size     = this.getSize();
          
                      const self = this;
          Severity: Major
          Found in public/js/main.js - About 2 hrs to fix

            Avoid excessively long variable names like $eventCollectionFactory. Keep variable name length under 20.
            Open

                    $eventCollectionFactory = new EventCollectionFactory(
            Severity: Minor
            Found in src/Server.php by phpmd

            LongVariable

            Since: 0.2

            Detects when a field, formal or local variable is declared with a long name.

            Example

            class Something {
                protected $reallyLongIntName = -3; // VIOLATION - Field
                public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
                    $otherReallyLongName = -5; // VIOLATION - Local
                    for ($interestingIntIndex = 0; // VIOLATION - For
                         $interestingIntIndex < 10;
                         $interestingIntIndex++ ) {
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#longvariable

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

                public function __construct(array $event, array $specialRepositories)
                {
                    parent::__construct(
                        (int) $event['id'],
                        new Type(Type::ISSUE_ACTION),
            Severity: Major
            Found in src/Event/GitHub/IssuesEvent.php and 1 other location - About 1 hr to fix
            src/Event/GitHub/PullRequestEvent.php on lines 19..32

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

            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

                public function __construct(array $event, array $specialRepositories)
                {
                    parent::__construct(
                        (int) $event['id'],
                        new Type(Type::PR_ACTION),
            Severity: Major
            Found in src/Event/GitHub/PullRequestEvent.php and 1 other location - About 1 hr to fix
            src/Event/GitHub/IssuesEvent.php on lines 19..32

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

            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

                public function __construct(array $event, array $specialRepositories)
                {
                    parent::__construct(
                        (int) $event['id'],
                        new Type(Type::PUSH_TO_REPOSITORY),
            Severity: Minor
            Found in src/Event/GitHub/PushEvent.php and 1 other location - About 1 hr to fix
            src/Event/GitHub/CreateEvent.php on lines 19..28

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

            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

                public function __construct(array $event, array $specialRepositories)
                {
                    parent::__construct(
                        (int) $event['id'],
                        new Type(Type::REPOSITORY_CREATED),
            Severity: Minor
            Found in src/Event/GitHub/CreateEvent.php and 1 other location - About 1 hr to fix
            src/Event/GitHub/PushEvent.php on lines 19..28

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

            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

            Avoid variables with short names like $id. Configured minimum length is 3.
            Open

                protected int $id;
            Severity: Minor
            Found in src/Event/BaseEvent.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            Avoid variables with short names like $id. Configured minimum length is 3.
            Open

                public function __construct(int $id, Type $type, Information $information, Ring $ring, BaseSound $sound)
            Severity: Minor
            Found in src/Event/BaseEvent.php by phpmd

            ShortVariable

            Since: 0.2

            Detects when a field, local, or parameter has a very short name.

            Example

            class Something {
                private $q = 15; // VIOLATION - Field
                public static function main( array $as ) { // VIOLATION - Formal
                    $r = 20 + $this->q; // VIOLATION - Local
                    for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                        $r += $this->q;
                    }
                }
            }

            Source https://phpmd.org/rules/naming.html#shortvariable

            The class Server has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13.
            Open

            final class Server
            {
                private LoggerInterface $logger;
            
                private Configuration $configuration;
            Severity: Minor
            Found in src/Server.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            The class Handler has a coupling between objects value of 13. Consider to reduce the number of dependencies under 13.
            Open

            class Handler implements ClientHandler, WebsocketServerObserver
            {
                private Gateway $gateway;
            
                private Listener $provider;
            Severity: Minor
            Found in src/Websocket/Handler.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

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

                public function __construct(int $id, Type $type, Information $information, Ring $ring, BaseSound $sound)
            Severity: Minor
            Found in src/Event/BaseEvent.php - About 35 mins to fix

              Avoid using static access to class '\Amp\Socket\Server' in method 'getSockets'.
              Open

                          fn (ServerAddress $address) => SocketServer::listen($address->getUri()),
              Severity: Minor
              Found in src/Server.php by phpmd

              StaticAccess

              Since: 1.4.0

              Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

              Example

              class Foo
              {
                  public function bar()
                  {
                      Bar::baz();
                  }
              }

              Source https://phpmd.org/rules/cleancode.html#staticaccess

              Avoid unused parameters such as '$response'.
              Open

                  public function handleClient(Gateway $gateway, Client $client, Request $request, Response $response): Promise
              Severity: Minor
              Found in src/Websocket/Handler.php by phpmd

              UnusedFormalParameter

              Since: 0.2

              Avoid passing parameters to methods or constructors and then not using those parameters.

              Example

              class Foo
              {
                  private function bar($howdy)
                  {
                      // $howdy is not used
                  }
              }

              Source https://phpmd.org/rules/unusedcode.html#unusedformalparameter

              Severity
              Category
              Status
              Source
              Language