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');
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>
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, [
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');
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) {
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;
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',
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, [
- Read upRead up
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([
Method handle
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function handle()
{
$group_ids = [];
$filtered = false;
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) {
- Read upRead up
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)
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(
- Read upRead up
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)
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) {
- Read upRead up
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();
- Read upRead up
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'));
Avoid too many return
statements within this method. Open
return response()->json(['error' => 'Unsupported event type'], 501);
Avoid too many return
statements within this method. Open
return $this->postTitleRelation($channelId, $corporationId, $titleId);
Avoid too many return
statements within this method. Open
return $this->postAllianceRelation($channelId, $allianceId);