warlof/slackbot

View on GitHub

Showing 26 of 220 total issues

Method up has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function up()
    {
        Schema::create('slack_channels', function (Blueprint $table) {
            $table->string('id');
            $table->string('name');
Severity: Major
Found in src/database/migrations/2016_06_24_003800_create_slackbot_tables.php - About 2 hrs to fix

    File SlackbotJsonController.php has 267 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    /**
     * This file is part of slackbot and provide user synchronization between both SeAT and a Slack Team
     *
     * Copyright (C) 2016, 2017, 2018, 2019  Loïc Leuilliot <loic.leuilliot@gmail.com>
    Severity: Minor
    Found in src/Http/Controllers/SlackbotJsonController.php - About 2 hrs to fix

      Method httpRequest has 43 lines of code (exceeds 25 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

        Method callback has 43 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function callback(Request $request)
            {
                // get back pending OAuth credentials validation from session
                $oauthCredentials = session()->get('warlof.slackbot.credentials');
        
        
        Severity: Minor
        Found in src/Http/Controllers/Services/OAuthController.php - About 1 hr to fix

          Method bindingSlackUser has 36 lines of code (exceeds 25 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 1 hr to fix

            Method getConnector has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                private function getConnector() : SlackApi
                {
                    if (!is_null($this->slack))
                        return $this->slack;
            
            
            Severity: Minor
            Found in src/Http/Controllers/Services/Traits/SlackApiConnector.php - About 1 hr to fix

              Method callback has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function callback(Request $request)
                  {
                      $this->validate($request, [
                          'token' => 'required|string',
                          'type' => 'required|in:url_verification,event_callback',
              Severity: Minor
              Found in src/Http/Controllers/Services/EventController.php - About 1 hr to fix

                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

                    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

                      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
                                Severity
                                Category
                                Status
                                Source
                                Language