JohnVanOrange/Core

View on GitHub

Showing 30 of 38 total issues

File Image.php has 542 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace JohnVanOrange\API;
use Imagick;

class Image extends Base {
Severity: Major
Found in src/API/Image.php - About 1 day to fix

    Function get has a Cognitive Complexity of 30 (exceeds 5 allowed). Consider refactoring.
    Open

     public function get($image, $sid = NULL, $session = NULL, $brazzify = FALSE) {
      $setting = new Setting;
      $current = $this->user->current($sid);
      //Get image data
      $query = new \Peyote\Select('images');
    Severity: Minor
    Found in src/API/Image.php - About 4 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

    Method get has 93 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

     public function get($image, $sid = NULL, $session = NULL, $brazzify = FALSE) {
      $setting = new Setting;
      $current = $this->user->current($sid);
      //Get image data
      $query = new \Peyote\Select('images');
    Severity: Major
    Found in src/API/Image.php - About 3 hrs to fix

      Image has 27 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class Image extends Base {
      
       private $user;
      
       public function __construct() {
      Severity: Minor
      Found in src/API/Image.php - About 3 hrs to fix

        File User.php has 280 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        <?php
        namespace JohnVanOrange\API;
        
        class User extends Base {
        
        
        Severity: Minor
        Found in src/API/User.php - About 2 hrs to fix

          Method processAdd has 67 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

           private function processAdd($path, $c_link=NULL, $sid = NULL) {
            $setting = new Setting;
            $web_root = $setting->get('web_root');
            $info = getimagesize($path);
            if (!$info) {
          Severity: Major
          Found in src/API/Image.php - About 2 hrs to fix

            Method call has 49 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

             public function call($method, $params=[]) {
                $result = explode('/',$method);
                $class = $result[0];
                $method = $result[1];
            
            
            Severity: Minor
            Found in src/API/API.php - About 1 hr to fix

              Method get has 34 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

               public function get($uid) {
                $query = new \Peyote\Select('media');
                $query->columns('media.uid',
                                'media.file',
                                'media.format',
              Severity: Minor
              Found in src/API/Media.php - About 1 hr to fix

                Method changepw has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                 public function changepw($password, $auth, $type = 'sid') {
                  if (!$password) throw new \Exception('Password is blank');
                  switch ($type) {
                   case 'pwreset':
                    $query = new \Peyote\Select('resources');
                Severity: Minor
                Found in src/API/User.php - About 1 hr to fix

                  Method add has 34 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                   public function add($name, $image, $sid = NULL) {
                    $setting = new Setting;
                    if ($setting->get('tags_need_auth')) {
                      $user = new User;
                      if ( !$user->isLoggedIn($sid) ) throw new \Exception('Must be logged in to add a tag', 1032);
                  Severity: Minor
                  Found in src/API/Tag.php - About 1 hr to fix

                    Function call has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
                    Open

                     public function call($method, $params=[]) {
                        $result = explode('/',$method);
                        $class = $result[0];
                        $method = $result[1];
                    
                    
                    Severity: Minor
                    Found in src/API/API.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 current has 31 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                     public function current($sid=NULL) {
                      if (!isset($sid)) $sid = $this->getSID();
                      $query = new \Peyote\Select('sessions');
                      $query->columns('user_id')
                            ->where('sid', '=', $sid)
                    Severity: Minor
                    Found in src/API/User.php - About 1 hr to fix

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

                       public function remove($image, $sid=NULL) {
                        if (!$this->canRemove($image, $sid)) throw new \JohnVanOrange\Core\Exception\NotAllowed('You don\'t have permission to remove this image', 401);
                        $data = $this->get($image, $sid);
                        //clean up resources
                        $query = new \Peyote\Delete('resources');
                      Severity: Minor
                      Found in src/API/Image.php - About 1 hr to fix

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

                         public function requestPwReset($username) {
                          $setting = new Setting;
                          $site_name = $setting->get('site_name');
                          $user = $this->get($username, 'username');
                          $uid = $this->getSecureID();
                        Severity: Minor
                        Found in src/API/User.php - About 1 hr to fix

                          Method get has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                           public function get($value, $search_by='image') {
                            $setting = new Setting;
                            if (!$value) throw new \JohnVanOrange\Core\Exception\NotFound('Tag value not set', 404);
                            switch ($search_by) {
                             case 'name':
                          Severity: Minor
                          Found in src/API/Tag.php - About 1 hr to fix

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

                             public function saved($username = NULL, $sid=NULL) {
                              $current = $this->current($sid);
                              if ($username) {
                               $user = $this->get($username, 'username');
                               if ($current['id'] != $user['id']) throw new \Exception('This users saved images are not publicly shared');
                            Severity: Minor
                            Found in src/API/User.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

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

                             public function uploaded($username = NULL, $sid=NULL) {
                              $current = $this->current($sid);
                              if ($username) {
                               $user = $this->get($username, 'username');
                               if ($current['id'] != $user['id']) throw new \Exception('This users uploaded images are not publicly shared');
                            Severity: Minor
                            Found in src/API/User.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

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

                             public function add($name, $image, $sid = NULL) {
                              $setting = new Setting;
                              if ($setting->get('tags_need_auth')) {
                                $user = new User;
                                if ( !$user->isLoggedIn($sid) ) throw new \Exception('Must be logged in to add a tag', 1032);
                            Severity: Minor
                            Found in src/API/Tag.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 __construct has 26 lines of code (exceeds 25 allowed). Consider refactoring.
                            Open

                              public function __construct($options = NULL) {
                            
                                parent::__construct('images');
                                $this->options = $options;
                            
                            
                            Severity: Minor
                            Found in src/API/ImageFilter/Base.php - About 1 hr to fix

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

                               public function current($sid=NULL) {
                                if (!isset($sid)) $sid = $this->getSID();
                                $query = new \Peyote\Select('sessions');
                                $query->columns('user_id')
                                      ->where('sid', '=', $sid)
                              Severity: Minor
                              Found in src/API/User.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

                              Severity
                              Category
                              Status
                              Source
                              Language