basalt-cms/basalt

View on GitHub

Showing 22 of 22 total issues

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

    public function save(User &$user)
    {
        if ($user->id) {
            $statement = $this->pdo->prepare('UPDATE `users` SET `email` = :email, `password` = :password WHERE `id` = :id');
            $statement->bindValue(':id', $user->id, PDO::PARAM_INT);
Severity: Major
Found in app/Basalt/Database/UserMapper.php and 1 other location - About 3 hrs to fix
app/Basalt/Database/SettingMapper.php on lines 30..48

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

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 save(Setting &$setting)
    {
        if ($setting->id) {
            $statement = $this->pdo->prepare('UPDATE `settings` SET `name` = :name, `value` = :value WHERE `id` = :id');
            $statement->bindValue(':id', $setting->id, PDO::PARAM_INT);
Severity: Major
Found in app/Basalt/Database/SettingMapper.php and 1 other location - About 3 hrs to fix
app/Basalt/Database/UserMapper.php on lines 49..67

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

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

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

class Uri implements UriInterface
{
    /**
     * @var array
     */
Severity: Minor
Found in app/Basalt/Http/Uri.php - About 3 hrs to fix

    File Uri.php has 293 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    namespace Basalt\Http;
    
    use InvalidArgumentException;
    Severity: Minor
    Found in app/Basalt/Http/Uri.php - About 3 hrs to fix

      Method add has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          public function add($name, $path, $action, $methods = [], $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
      Severity: Major
      Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

        Method addPost has 8 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            public function addPost($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
        Severity: Major
        Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

          Method addPut has 8 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              public function addPut($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
          Severity: Major
          Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

            Method addPatch has 8 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                public function addPatch($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
            Severity: Major
            Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

              Method addTrace has 8 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  public function addTrace($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
              Severity: Major
              Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

                Method addDelete has 8 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    public function addDelete($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
                Severity: Major
                Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

                  Method addOptions has 8 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      public function addOptions($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
                  Severity: Major
                  Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

                    Method addConnect has 8 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        public function addConnect($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
                    Severity: Major
                    Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

                      Method addGet has 8 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          public function addGet($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
                      Severity: Major
                      Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

                        Method addHead has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            public function addHead($name, $path, $action, $defaults = [], $requirements = [], $options = [], $host = '', $schemes = [])
                        Severity: Major
                        Found in app/Basalt/Facades/RoutesFacade.php - About 1 hr to fix

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

                              private static function createUriString($scheme, $authority, $path, $query, $fragment)
                              {
                                  $uri = '';
                                  
                                  if (!empty($scheme)) {
                          Severity: Minor
                          Found in app/Basalt/Http/Uri.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 filterHeaders has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                          Open

                              private function filterHeaders(array $originalHeaders)
                              {
                                  $headersMap = $headers = [];
                          
                                  foreach ($originalHeaders as $header => $value) {
                          Severity: Minor
                          Found in app/Basalt/Http/MessageTrait.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

                          Method createUriString has 5 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              private static function createUriString($scheme, $authority, $path, $query, $fragment)
                          Severity: Minor
                          Found in app/Basalt/Http/Uri.php - About 35 mins to fix

                            Avoid too many return statements within this method.
                            Open

                                        return new Flash;
                            Severity: Major
                            Found in app/Basalt/Providers/AppServiceProvider.php - About 30 mins to fix

                              Avoid too many return statements within this method.
                              Open

                                          return $twig;
                              Severity: Major
                              Found in app/Basalt/Providers/TwigServiceProvider.php - About 30 mins to fix

                                Avoid too many return statements within this method.
                                Open

                                            return new UrlHelper($container->generator, $container->routes);
                                Severity: Major
                                Found in app/Basalt/Providers/AppServiceProvider.php - About 30 mins to fix
                                  Severity
                                  Category
                                  Status
                                  Source
                                  Language