digitalbiblesociety/dbp

View on GitHub
app/Http/Controllers/User/UsersControllerV2.php

Summary

Maintainability
A
3 hrs
Test Coverage

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

    public function login()
    {
        $email    = request()->email ?? request()->login;
        $provider = request()->remote_type;
        $password = request()->password;
Severity: Minor
Found in app/Http/Controllers/User/UsersControllerV2.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

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

    public function highlightAlter()
    {
        if ($this->hash === request()->hash) {
            if (request()->method() == 'DELETE') {
                $deletedHighlight = Highlight::where('id', request()->id)->delete();
Severity: Minor
Found in app/Http/Controllers/User/UsersControllerV2.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

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

    public function noteAlter()
    {
        if ($this->hash === request()->hash) {

            if(request()->_method === 'delete') {
Severity: Minor
Found in app/Http/Controllers/User/UsersControllerV2.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->setStatusCode(401)->replyWithError('hash does not match');
Severity: Major
Found in app/Http/Controllers/User/UsersControllerV2.php - About 30 mins to fix

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

        public function user()
        {
            if (request()->getMethod() === 'POST') {
                $user = $user = User::where('email', request()->email)->first();
                if (!$user) {
    Severity: Minor
    Found in app/Http/Controllers/User/UsersControllerV2.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

    There are no issues that match your filters.

    Category
    Status