warlof/slackbot

View on GitHub

Showing 220 of 220 total issues

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

    private function httpRequest(string $method, string $uri, array $headers = [], array $body = []) : SlackResponse
    {
        $request_body = null;

        $headers = array_merge($headers, [
Severity: Minor
Found in src/Repositories/Slack/Fetchers/GuzzleFetcher.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 fetchSlackConversationMembers has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function fetchSlackConversationMembers(string $channel_id, string $cursor = null) : array
    {
        sleep(1);

        $this->getConnector()->setQueryString([
Severity: Minor
Found in src/Http/Controllers/Services/Traits/SlackApiConnector.php - About 1 hr to fix

    Method handle has 26 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function handle()
        {
            $group_ids = [];
            $filtered = false;
    
    
    Severity: Minor
    Found in src/Commands/SlackUserSync.php - About 1 hr to fix

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

              Schema::create('slack_channel_alliances', function (Blueprint $table) {
                  $table->integer('alliance_id');
                  $table->string('channel_id');
                  $table->boolean('enable');
                  $table->timestamps();
      src/database/migrations/2016_06_24_003800_create_slackbot_tables.php on lines 71..83

      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

              Schema::create('slack_channel_corporations', function (Blueprint $table) {
                  $table->integer('corporation_id');
                  $table->string('channel_id');
                  $table->boolean('enable');
                  $table->timestamps();
      src/database/migrations/2016_06_24_003800_create_slackbot_tables.php on lines 57..69

      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

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

          private function refreshSlackUsername()
          {
              $users = SlackUser::with('group')->whereNull('name')->get();
      
              if ($users->count() > 0) {
      Severity: Minor
      Found in src/Http/Controllers/SlackbotController.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

      Method logRequest has 7 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          private function logRequest(string $level, string $method, string $uri, string $request_body = null, ResponseInterface $response, $response_body, $request_time)
      Severity: Major
      Found in src/Repositories/Slack/Fetchers/GuzzleFetcher.php - About 50 mins to fix

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

            private function mapDataToUri(string $uri, array $data) : string
            {
                if (preg_match('/{+(.*?)}/', $uri, $matches)) {
                    if (empty($data))
                        throw new UriDataMissingException(
        Severity: Minor
        Found in src/Repositories/Slack/SlackApi.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 4 locations. Consider refactoring.
        Open

            public function removeAlliance($alliance_id, $channel_id)
            {
                $channelAlliance = SlackChannelAlliance::where('alliance_id', $alliance_id)
                    ->where('channel_id', $channel_id);
        
        
        Severity: Major
        Found in src/Http/Controllers/SlackbotJsonController.php and 3 other locations - About 40 mins to fix
        src/Http/Controllers/SlackbotJsonController.php on lines 134..147
        src/Http/Controllers/SlackbotJsonController.php on lines 154..167
        src/Http/Controllers/SlackbotJsonController.php on lines 174..187

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

            public function removeUser($group_id, $channel_id)
            {
                $channelUser = SlackChannelUser::where('group_id', $group_id)
                    ->where('channel_id', $channel_id);
        
        
        Severity: Major
        Found in src/Http/Controllers/SlackbotJsonController.php and 3 other locations - About 40 mins to fix
        src/Http/Controllers/SlackbotJsonController.php on lines 154..167
        src/Http/Controllers/SlackbotJsonController.php on lines 174..187
        src/Http/Controllers/SlackbotJsonController.php on lines 216..229

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

            public function removeRole($role_id, $channel_id)
            {
                $channelRole = SlackChannelRole::where('role_id', $role_id)
                    ->where('channel_id', $channel_id);
        
        
        Severity: Major
        Found in src/Http/Controllers/SlackbotJsonController.php and 3 other locations - About 40 mins to fix
        src/Http/Controllers/SlackbotJsonController.php on lines 134..147
        src/Http/Controllers/SlackbotJsonController.php on lines 174..187
        src/Http/Controllers/SlackbotJsonController.php on lines 216..229

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

            public function removeCorporation($corporation_id, $channel_id)
            {
                $channelCorporation = SlackChannelCorporation::where('corporation_id', $corporation_id)
                    ->where('channel_id', $channel_id);
        
        
        Severity: Major
        Found in src/Http/Controllers/SlackbotJsonController.php and 3 other locations - About 40 mins to fix
        src/Http/Controllers/SlackbotJsonController.php on lines 134..147
        src/Http/Controllers/SlackbotJsonController.php on lines 154..167
        src/Http/Controllers/SlackbotJsonController.php on lines 216..229

        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

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

            private function getResponseContext(string $uri, string $request_body = null, ResponseInterface $response, $response_body, $request_time)
        Severity: Minor
        Found in src/Repositories/Slack/Fetchers/GuzzleFetcher.php - About 35 mins to fix

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

              private function bindingSlackUser(Collection $users)
              {
                  logger()->debug('bindingSlackUser', ['users' => $users]);
          
                  foreach ($users as $user) {
          Severity: Minor
          Found in src/Jobs/SyncUser.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 processMappingBase has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
          Open

              private function processMappingBase(array $members)
              {
                  $pending_kicks = collect();
                  $pending_invitations = collect();
          
          
          Severity: Minor
          Found in src/Jobs/ConversationOrchestrator.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->eventHandler($request->input('event'));
          Severity: Major
          Found in src/Http/Controllers/Services/EventController.php - About 30 mins to fix

            Avoid too many return statements within this method.
            Open

                    return response()->json(['error' => 'Unsupported event type'], 501);
            Severity: Major
            Found in src/Http/Controllers/Services/EventController.php - About 30 mins to fix

              Avoid too many return statements within this method.
              Open

                              return $this->postTitleRelation($channelId, $corporationId, $titleId);
              Severity: Major
              Found in src/Http/Controllers/SlackbotJsonController.php - About 30 mins to fix

                Avoid too many return statements within this method.
                Open

                                return $this->postAllianceRelation($channelId, $allianceId);
                Severity: Major
                Found in src/Http/Controllers/SlackbotJsonController.php - About 30 mins to fix

                  Avoid too many return statements within this method.
                  Open

                                      return response()->json(null, 400);
                  Severity: Major
                  Found in src/Http/Controllers/Services/EventController.php - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language