JohnVanOrange/Core

View on GitHub

Showing 38 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

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

     public function like($image, $sid = NULL, $session = NULL) {
      if (!$image) throw new \Exception('Must provide image ID', 1040);
      $current = $this->user->current($sid);
      $query = new \Peyote\Delete('resources');
      $query->where('image', '=', $image)
    Severity: Major
    Found in src/API/Image.php and 1 other location - About 1 day to fix
    src/API/Image.php on lines 63..86

    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 249.

    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

     public function dislike($image, $sid = NULL, $session = NULL) {
      if (!$image) throw new \Exception('Must provide image ID', 1040);
      $current = $this->user->current($sid);
      $query = new \Peyote\Delete('resources');
      $query->where('image', '=', $image)
    Severity: Major
    Found in src/API/Image.php and 1 other location - About 1 day to fix
    src/API/Image.php on lines 26..49

    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 249.

    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

     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: Major
    Found in src/API/User.php and 1 other location - About 7 hrs to fix
    src/API/User.php on lines 257..282

    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 232.

    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

     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: Major
    Found in src/API/User.php and 1 other location - About 7 hrs to fix
    src/API/User.php on lines 295..320

    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 232.

    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 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

                            Severity
                            Category
                            Status
                            Source
                            Language