fulldecent/cameralife

View on GitHub

Showing 127 of 127 total issues

File Photo.php has 514 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
namespace CameraLife\Models;

/**
 * Class Photo provides a front end to working with photos
Severity: Major
Found in sources/Models/Photo.php - About 1 day to fix

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

        public function handlePost($get, $post, $files, $cookies)
        {
            if (Models\User::currentUser($cookies)->authorizationLevel < 5) {
                throw new \Exception('You are not authorized to view this page');
            }
    Severity: Major
    Found in sources/Controllers/AdminFileStoreController.php and 1 other location - About 7 hrs to fix
    sources/Controllers/AdminAppearanceController.php on lines 48..77

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

    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

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

        public function handlePost($get, $post, $files, $cookies)
        {
            if (Models\User::currentUser($cookies)->authorizationLevel < 5) {
                throw new \Exception('You are not authorized to view this page');
            }
    Severity: Major
    Found in sources/Controllers/AdminAppearanceController.php and 1 other location - About 7 hrs to fix
    sources/Controllers/AdminFileStoreController.php on lines 43..72

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

    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

    Method doUpgrade has 177 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function doUpgrade()
        {
            //Database::beginTransaction();
            $sql = '
            CREATE TABLE "albums" (
    Severity: Major
    Found in sources/Models/SchemaUpdaterSqlite0.php - About 7 hrs to fix

      Function loadEXIF has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring.
      Open

          private function loadEXIF($file)
          {
              $exif = @exif_read_data($file, 'IFD0', true);
              if ($exif === false) {
                  return;
      Severity: Minor
      Found in sources/Models/Photo.php - About 6 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 setupTables has 137 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public static function setupTables()
          {
              empty(self::$pdoConnection) && self::connect();
              $prefix = self::$prefix;
      
      
      Severity: Major
      Found in sources/Models/Database.php - About 5 hrs to fix

        Function listFiles has a Cognitive Complexity of 32 (exceeds 5 allowed). Consider refactoring.
        Open

            public function listFiles($path = '/', $recursive = true)
            {
                $fullpath = $this->baseDir . $path;
        
                // FEATURE // add " NOCL" to the end of a folder to exclude it
        Severity: Minor
        Found in sources/Models/FileStore.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

        Function render has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
        Open

            public function render()
            {
                echo "<h2>Settings for " . $this->moduleName . "</h2>\n";
                if (isset($module->about)) {
                    echo "<p class=\"lead\">" . $module->about . "</p>\n";
        Severity: Minor
        Found in sources/Views/AdminPreferencesView.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 loadEXIF has 98 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            private function loadEXIF($file)
            {
                $exif = @exif_read_data($file, 'IFD0', true);
                if ($exif === false) {
                    return;
        Severity: Major
        Found in sources/Models/Photo.php - About 3 hrs to fix

          Method handleGet has 95 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function handleGet($get, $post, $files, $cookies)
              {
                  // todo, get PREV and NEXT links from photo and use meta prev/next in HTML theme header
          
                  $this->htmlBareHeader($cookies);
          Severity: Major
          Found in sources/Controllers/PhotoController.php - About 3 hrs to fix

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

                private function checkPrerequesites()
                {
                    global $_SERVER;
                    $prerequesitesAreMet = true;
            
            
            Severity: Major
            Found in sources/Controllers/SetupInstallController.php - About 3 hrs to fix

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

                  protected function renderNavbar($cookies = array())
                  {
                      $navbarView = new Views\NavbarView;
                      $navbarView->openGraphObject = $this;
                      $navbarView->currentUser = Models\User::currentUser($cookies);
              Severity: Major
              Found in sources/Controllers/HtmlController.php and 1 other location - About 3 hrs to fix
              sources/Controllers/HtmlController.php on lines 25..38

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

              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

                  protected function htmlBareHeader($cookies = array())
                  {
                      $view = new Views\HeaderView;
                      $view->openGraphObject = $this;
                      $view->currentUser = Models\User::currentUser($cookies);
              Severity: Major
              Found in sources/Controllers/HtmlController.php and 1 other location - About 3 hrs to fix
              sources/Controllers/HtmlController.php on lines 41..54

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

              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

              Method render has 89 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  public function render()
                  {
                      if ($this->photo->get('status') != 0) {
                          echo '<p class="alert alert-danger lead"><strong>Notice:</strong> This photo is not publicly viewable</p>';
                      }
              Severity: Major
              Found in sources/Views/PhotoView.php - About 3 hrs to fix

                Photo has 29 functions (exceeds 20 allowed). Consider refactoring.
                Open

                class Photo extends IndexedModel
                {
                    public $record;
                
                    public $image;
                Severity: Minor
                Found in sources/Models/Photo.php - About 3 hrs to fix

                  Method render has 87 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      public function render()
                      {
                          if (!count($this->openGraphsForTop)) {
                          ?>
                              </div>
                  Severity: Major
                  Found in sources/Views/MainPageView.php - About 3 hrs to fix

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

                            switch ($view->activeSection) {
                                case 'newest-folders':
                                    $search->sort = 'newest';
                                    foreach ($search->getFolders() as $folder) {
                                        $view->openGraphsForTop[] = new FolderController($folder->id);
                    Severity: Major
                    Found in sources/Controllers/AllTagCollectionsController.php and 1 other location - About 3 hrs to fix
                    sources/Controllers/MainPageController.php on lines 36..57

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

                    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

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

                            switch ($view->activeSection) {
                                case 'newest-folders':
                                    $search->sort = 'newest';
                                    foreach ($search->getFolders() as $folder) {
                                        $view->openGraphsForTop[] = new FolderController($folder->id);
                    Severity: Major
                    Found in sources/Controllers/MainPageController.php and 1 other location - About 3 hrs to fix
                    sources/Controllers/AllTagCollectionsController.php on lines 31..52

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

                    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

                    Method render has 77 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        public function render()
                        {
                            echo <<<EOL
                            <!-- CAMERALIFE PHONE HOME Global site tag (gtag.js) - Google Analytics -->
                            <script async src="https://www.googletagmanager.com/gtag/js?id=UA-52764-13"></script>
                    Severity: Major
                    Found in sources/Views/AdminView.php - About 3 hrs to fix

                      File Database.php has 295 lines of code (exceeds 250 allowed). Consider refactoring.
                      Open

                      <?php
                      namespace CameraLife\Models;
                      
                      /**
                       * PDO wrapper implementation of the database class
                      Severity: Minor
                      Found in sources/Models/Database.php - About 3 hrs to fix
                        Severity
                        Category
                        Status
                        Source
                        Language