warlof/seat-teamspeak

View on GitHub

Showing 21 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

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

        public function addMember(IUser $user)
        {
            if (in_array($user, $this->getMembers()))
                return;
    
    
    Severity: Major
    Found in src/Driver/TeamspeakServerGroup.php and 1 other location - About 2 hrs to fix
    src/Driver/TeamspeakSpeaker.php on lines 122..135

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

    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 addSet(ISet $group)
        {
            if (in_array($group, $this->getSets()))
                return;
    
    
    Severity: Major
    Found in src/Driver/TeamspeakSpeaker.php and 1 other location - About 2 hrs to fix
    src/Driver/TeamspeakServerGroup.php on lines 100..113

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

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

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

        public function removeSet(ISet $group)
        {
            if (! in_array($group, $this->getSets()))
                return;
    
    
    Severity: Major
    Found in src/Driver/TeamspeakSpeaker.php and 1 other location - About 2 hrs to fix
    src/Driver/TeamspeakServerGroup.php on lines 119..132

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

    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 removeMember(IUser $user)
        {
            if (! in_array($user, $this->getMembers()))
                return;
    
    
    Severity: Major
    Found in src/Driver/TeamspeakServerGroup.php and 1 other location - About 2 hrs to fix
    src/Driver/TeamspeakSpeaker.php on lines 141..154

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

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

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

            public function getSets(): array
            {
                if ($this->server_groups->isEmpty()) {
                    try {
                        $this->server_groups = collect(TeamspeakClient::getInstance()->getSpeakerServerGroups($this));
        Severity: Major
        Found in src/Driver/TeamspeakSpeaker.php and 1 other location - About 1 hr to fix
        src/Driver/TeamspeakServerGroup.php on lines 82..94

        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 getMembers(): array
            {
                if ($this->members->isEmpty()) {
                    try {
                        $this->members = collect(TeamspeakClient::getInstance()->getServerGroupMembers($this));
        Severity: Major
        Found in src/Driver/TeamspeakServerGroup.php and 1 other location - About 1 hr to fix
        src/Driver/TeamspeakSpeaker.php on lines 104..116

        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

        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

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

                  public function getUsers(): array
                  {
                      if ($this->speakers->isEmpty()) {
                          try {
                              $this->seedSpeakers();
              Severity: Minor
              Found in src/Driver/TeamspeakClient.php and 1 other location - About 35 mins to fix
              src/Driver/TeamspeakClient.php on lines 170..182

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

              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 getSets(): array
                  {
                      if ($this->server_groups->isEmpty()) {
                          try {
                              $this->seedServerGroups();
              Severity: Minor
              Found in src/Driver/TeamspeakClient.php and 1 other location - About 35 mins to fix
              src/Driver/TeamspeakClient.php on lines 152..164

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

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

              Severity
              Category
              Status
              Source
              Language