Kylob/BootPress

View on GitHub

Showing 16,700 of 16,700 total issues

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

        foreach ($this->startStop(168, 'hour', 'Y-m-d H:i:s') as $x => $info) { // D M j
            list($start, $stop) = $info;
            $this->db->execute($stmt, array($start, $stop));
            list($loaded, $server) = $this->db->fetch($stmt);
            $data[] = '{x:"'.$x.'", loaded:'.round($loaded, 2).', server:'.round($server, 2).'}';
Severity: Major
Found in src/Admin/Pages/Analytics.php and 2 other locations - About 2 hrs to fix
src/Admin/Pages/Analytics.php on lines 697..702
src/Admin/Pages/Analytics.php on lines 754..759

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

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 3 locations. Consider refactoring.
Open

        foreach ($this->startStop(180, 'day', 'Y-m-d H:i:s') as $x => $info) { // D M j
            list($start, $stop) = $info;
            $this->db->execute($stmt, array($start, $stop));
            list($loaded, $server) = $this->db->fetch($stmt);
            $data[] = '{x:"'.$x.'", loaded:'.round($loaded, 2).', server:'.round($server, 2).'}';
Severity: Major
Found in src/Admin/Pages/Analytics.php and 2 other locations - About 2 hrs to fix
src/Admin/Pages/Analytics.php on lines 697..702
src/Admin/Pages/Analytics.php on lines 725..730

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

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 box has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static function box($style, array $contents)
    {
        $box = '';
        $classes = 'box box-'.implode(' box-', explode(' ', $style)); // solid, default, primary, info, warning, success, danger
        foreach ($contents as $section => $value) {
Severity: Minor
Found in src/Admin/Component.php - About 2 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 sidebar has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
Open

    public static function sidebar($links, $prepend = false)
    {
        if (is_array($links)) {
            $page = Page::html();
            foreach ($links as $name => $path) {
Severity: Minor
Found in src/Admin/Component.php - About 2 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 blueimpFileUploader has 58 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    $.fn.blueimpFileUploader = function(options) {
        var action = $(this).closest('form').attr('action');
        var field = $(this).attr('id');
        var settings = $.extend({
            'size': 0,
Severity: Major
Found in src/Upload/uploader.js - About 2 hrs to fix

    File wyciwyg.js has 263 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    /* From: Alex Brem @ http://blog.0xab.cd - fieldSelection jQuery plugin */
    (function() {
        var fieldSelection = {
            getSelection: function() {
                var e = (this.jquery) ? this[0] : this;
    Severity: Minor
    Found in src/Admin/Pages/admin/wyciwyg.js - About 2 hrs to fix

      Method pages has 56 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function pages()
          {
              extract(Admin::params('bp', 'website', 'page', 'path', 'admin'));
              $page->title = 'Analytic Pages at '.$website;
              $url = $page->url($admin, $path, 'users'); // for linking most recent users
      Severity: Major
      Found in src/Admin/Pages/Analytics.php - About 2 hrs to fix

        Method page has 56 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public static function page()
            {
                extract(Admin::params('bp', 'blog', 'auth', 'page', 'admin', 'path', 'method'));
                if ($method) {
                    switch ($method) {
        Severity: Major
        Found in src/Admin/Pages/Blog.php - About 2 hrs to fix

          Function collect has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
          Open

              public function collect()
              {
                  $logs = array(
                      'nb_databases' => 0,
                      'nb_statements' => 0,
          Severity: Minor
          Found in src/DebugBar/Collector/Queries.php - About 2 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 editUser has 51 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              private static function editUser($user_id)
              {
                  extract(Admin::params('bp', 'page', 'auth', 'website'));
                  $page->title = 'Edit User at '.$website;
                  $html = '';
          Severity: Major
          Found in src/Admin/Pages/Users.php - About 2 hrs to fix

            Method update has 50 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                public function update($user_id, array $user = array())
                {
                    $update = array();
                    foreach ($user as $key => $value) {
                        switch ($key) {
            Severity: Minor
            Found in src/Auth/Component.php - About 2 hrs to fix

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

                  public function __call($method, $arguments)
                  {
                      switch ($method) {
                          case 'start':
                              if (self::$debugbar->hasCollector('time')) {
              Severity: Minor
              Found in src/DebugBar/Component.php - About 1 hr to fix

                Method restore has 48 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    private static function restore()
                    {
                        extract(Admin::params('bp', 'page', 'blog', 'website'));
                        $page->title = 'Restore Blog at '.$website;
                        $html = '';
                Severity: Minor
                Found in src/Admin/Pages/Blog.php - About 1 hr to fix

                  Function listUsers has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
                  Open

                      private static function listUsers($view)
                      {
                          extract(Admin::params('bp', 'page', 'auth', 'website'));
                          $page->title = 'View Users at '.$website;
                          $html = '';
                  Severity: Minor
                  Found in src/Admin/Pages/Users.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 referrers has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                      private function referrers()
                      {
                          extract(Admin::params('bp', 'website', 'page'));
                          $page->title = 'Referrer Analytics at '.$website;
                          $db = BPA::database();
                  Severity: Minor
                  Found in src/Admin/Pages/Analytics.php - About 1 hr to fix

                    Method getFileHeader has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                        private function getFileHeader($start_offset = false)
                        {
                            if ($start_offset !== false) {
                                fseek($this->fh, $start_offset);
                            }
                    Severity: Minor
                    Found in src/Unzip/Component.php - About 1 hr to fix

                      Method box has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                          public static function box($style, array $contents)
                          {
                              $box = '';
                              $classes = 'box box-'.implode(' box-', explode(' ', $style)); // solid, default, primary, info, warning, success, danger
                              foreach ($contents as $section => $value) {
                      Severity: Minor
                      Found in src/Admin/Component.php - About 1 hr to fix

                        Method sessions has 45 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                            private static function sessions($user_id)
                            {
                                extract(Admin::params('bp', 'page', 'auth'));
                                $html = '';
                                if (!$bp->pagination->set('sessions', 10)) {
                        Severity: Minor
                        Found in src/Admin/Pages/Users.php - About 1 hr to fix

                          Method editProfile has 44 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                              private static function editProfile($user_id)
                              {
                                  extract(Admin::params('bp', 'page', 'auth', 'website'));
                                  $page->title = 'Edit Your Profile at '.$website;
                                  $html = '';
                          Severity: Minor
                          Found in src/Admin/Pages/Users.php - About 1 hr to fix

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

                                    this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) + $(window).scrollLeft()) + "px");
                            Severity: Major
                            Found in src/Admin/Pages/admin/wyciwyg.js and 1 other location - About 1 hr to fix
                            src/Admin/Pages/admin/wyciwyg.js on lines 189..189

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

                            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

                            Severity
                            Category
                            Status
                            Source
                            Language