antaresproject/core

View on GitHub

Showing 306 of 306 total issues

Function setValueOptions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function setValueOptions($options): MultiCheckboxType
    {
        if (is_array($options) || $options instanceof \Traversable) {
            foreach ($options as $key => $value) {
                if (!$value instanceof Option) {
Severity: Minor
Found in src/utils/form/src/Controls/MultiCheckboxType.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 setValueOptions has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function setValueOptions($options): SelectType
    {
        if (is_array($options) || $options instanceof \Traversable) {
            foreach ($options as $key => $value) {
                if (!$value instanceof Option) {
Severity: Minor
Found in src/utils/form/src/Controls/SelectType.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 registerEventListeners has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function registerEventListeners(DispatcherContract $events)
    {
        foreach ($this->listen as $event => $listeners) {
            $defaultPriority = 0;
            if (!is_array($listeners)) {
Severity: Minor
Found in src/components/support/src/Providers/Traits/EventProviderTrait.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 customfieldsByFieldset has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function customfieldsByFieldset($grid, $name)
    {
        if (!extension_active('customfields')) {
            return;
        }
Severity: Minor
Found in src/components/html/src/Form/Fieldset.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 resolveUIComponentNamespace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolveUIComponentNamespace($src, $i = 0)
    {
        $tokens       = token_get_all($src);
        $count        = count($tokens);
        $namespace    = '';
Severity: Minor
Found in src/ui/components/templates/src/Finder.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 resolveNamespace has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    public function resolveNamespace(string $path, bool $asPackage = false): string
    {
        $file       = new File($path);
        $pathInfo   = array_filter(explode(DIRECTORY_SEPARATOR, trim(str_replace([$this->configRepository->getRootPath(), 'src'], '', $file->getRealPath()), DIRECTORY_SEPARATOR)));
        $prefix     = 'antares';
Severity: Minor
Found in src/components/extension/src/FilesystemFinder.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 columnSearch has 39 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function columnSearch()
    {
        $columns = $this->request->get('columns', []);

        foreach ($columns as $index => $column) {
Severity: Minor
Found in src/ui/components/datatables/src/Engines/QueryBuilderEngine.php - About 1 hr to fix

    Method min has 39 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function min()
        {
            if ($this->output !== '') { // min already run
                return $this->output;
            }
    Severity: Minor
    Found in src/utils/asset/src/JSMin.php - About 1 hr to fix

      Method setDefaultOptions has 38 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          protected function setDefaultOptions()
          {
              $areas         = array_keys(config('areas.areas'));
              $default       = config('areas.default');
              $configuration = require_once(__DIR__ . '/../../../../../modules/brands/resources/config/install.php');

        Method getActionsColumn has 38 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            protected function getActionsColumn(Authorization $acl): Closure
            {
                return function(ExtensionContract $extension) use($acl) {
                    $buttons = [];
                    $name    = $extension->getPackage()->getName();
        Severity: Minor
        Found in src/foundation/src/Http/Datatables/Extensions.php - About 1 hr to fix

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

              protected function getLowerRoles(array $elements, $parentId = 0, &$return = [])
              {
                  foreach ($elements as $element) {
                      if ($element['parent_id'] != $parentId) {
                          continue;
          Severity: Major
          Found in src/components/model/src/Role.php and 1 other location - About 1 hr to fix
          src/utils/security/src/Scope/AccessScope.php on lines 121..137

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

          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

              protected function getLowerRoles(array $elements, $parentId = 0, &$return = [])
              {
                  foreach ($elements as $element) {
                      if ($element['parent_id'] != $parentId) {
                          continue;
          Severity: Major
          Found in src/utils/security/src/Scope/AccessScope.php and 1 other location - About 1 hr to fix
          src/components/model/src/Role.php on lines 182..198

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

          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 37 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function render()
              {
                  $dropzoneAttributes = array_diff_key($this->field->attributes, array_flip(['class']));
          
                  if (!isset($dropzoneAttributes['container'])) {
          Severity: Minor
          Found in src/components/html/src/Control/Dropzone.php - About 1 hr to fix

            Method registerEngine has 37 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                protected function registerEngine()
                {
                    $this->app->bindIf('twig', function () {
                        $extensions = $this->app->make('twig.extensions');
                        $lexer      = $this->app->make('twig.lexer');
            Severity: Minor
            Found in src/utils/testbench/src/Providers/TwigServiceProvider.php - About 1 hr to fix

              Method argumentsToString has 37 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                  protected function argumentsToString($args)
                  {
                      $count = 0;
              
                      $isAssoc = $args !== array_values($args);
              Severity: Minor
              Found in src/components/exception/Handler.php - About 1 hr to fix

                Method decorate has 36 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                    public static function decorate($value, $safe = false)
                    {
                        if (is_string($value)) {
                            if (strpos($value, 'js:') === 0 && $safe === false)
                                return substr($value, 3);
                Severity: Minor
                Found in src/utils/asset/src/JavaScriptDecorator.php - About 1 hr to fix

                  Function requireJs has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function requireJs()
                      {
                          $scripts = $this->dispatcher->scripts('script', $this->assets, $this->path);
                  
                          $required = [];
                  Severity: Minor
                  Found in src/utils/asset/src/Asset.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 getPatterned has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function getPatterned($value)
                      {
                          if (!is_array($value)) {
                              return str_replace('%value', ucfirst($value), $this->pattern);
                          } else {
                  Severity: Minor
                  Found in src/ui/components/datatables/src/Filter/AbstractFilter.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 beforeTable has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      protected function beforeTable()
                      {
                          $hasMassActions  = $this->hasMassActions();
                          $filters         = $this->filterAdapter->getFilters();
                          $hasColumnFilter = $this->hasColumnFilter();
                  Severity: Minor
                  Found in src/ui/components/datatables/src/Html/Builder.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 findExtensions has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                  Open

                      public function findExtensions(): Extensions
                      {
                          $extensions = new Extensions();
                  
                  
                  
                  Severity: Minor
                  Found in src/components/extension/src/FilesystemFinder.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