warlof/seat-teamspeak

View on GitHub

Showing 13 of 21 total issues

File TeamspeakClient.php has 329 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * This file is part of SeAT Teamspeak Connector.
 *
 * Copyright (C) 2019  Warlof Tutsimo <loic.leuilliot@gmail.com>
Severity: Minor
Found in src/Driver/TeamspeakClient.php - About 3 hrs to fix

    Function getInstance has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function getInstance(): IClient
        {
            if (! isset(self::$instance)) {
                try {
                    $settings = setting('seat-connector.drivers.teamspeak', true);
    Severity: Minor
    Found in src/Driver/TeamspeakClient.php - About 2 hrs 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 sendCall has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        private function sendCall(string $method, string $endpoint, array $arguments = []): array
        {
            $uri = ltrim($endpoint, '/');
            $method = strtoupper($method);
    
    
    Severity: Minor
    Found in src/Driver/TeamspeakClient.php - About 1 hr to fix

      Method handleProviderCallback has 40 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function handleProviderCallback()
          {
              // determine the expected nickname for that user
              $searched_nickname = session('seat-connector.teamspeak.registration_uuid');
      
      
      Severity: Minor
      Found in src/Http/Controllers/RegistrationController.php - About 1 hr to fix

        Method getUser has 33 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getUser(string $id): ?IUser
            {
                if ($this->speakers->isEmpty()) {
                    try {
                        $this->seedSpeakers();
        Severity: Minor
        Found in src/Driver/TeamspeakClient.php - About 1 hr to fix

          Function sendCall has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
          Open

              private function sendCall(string $method, string $endpoint, array $arguments = []): array
              {
                  $uri = ltrim($endpoint, '/');
                  $method = strtoupper($method);
          
          
          Severity: Minor
          Found in src/Driver/TeamspeakClient.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 findUserByName has 30 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function findUserByName(string $nickname)
              {
                  try {
                      // scope: manage_scope
                      $response = $this->sendCall('GET', '/{instance}/clientdbfind', [
          Severity: Minor
          Found in src/Driver/TeamspeakClient.php - About 1 hr to fix

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

                public function handleProviderCallback()
                {
                    // determine the expected nickname for that user
                    $searched_nickname = session('seat-connector.teamspeak.registration_uuid');
            
            
            Severity: Minor
            Found in src/Http/Controllers/RegistrationController.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 getInstance has 27 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public static function getInstance(): IClient
                {
                    if (! isset(self::$instance)) {
                        try {
                            $settings = setting('seat-connector.drivers.teamspeak', true);
            Severity: Minor
            Found in src/Driver/TeamspeakClient.php - About 1 hr to fix

              Function seedSpeakers has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  private function seedSpeakers()
                  {
                      $from        = 0;
              
                      while (true) {
              Severity: Minor
              Found in src/Driver/TeamspeakClient.php - 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

              Function getUser has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
              Open

                  public function getUser(string $id): ?IUser
                  {
                      if ($this->speakers->isEmpty()) {
                          try {
                              $this->seedSpeakers();
              Severity: Minor
              Found in src/Driver/TeamspeakClient.php - 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

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

                  private function seedServerGroups()
                  {
                      // scope: manage_scope
                      $response = $this->sendCall('GET', '/{instance}/serverinfo', [
                          'instance' => $this->instance_id,
              Severity: Minor
              Found in src/Driver/TeamspeakClient.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

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

                  public function redirectToProvider()
                  {
                      try {
                          $settings = setting('seat-connector.drivers.teamspeak', true);
              
              
              Severity: Minor
              Found in src/Http/Controllers/RegistrationController.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