keboola/gooddata-php-client

View on GitHub
src/ProjectModel.php

Summary

Maintainability
D
2 days
Test Coverage

Function diff has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
Open

    public function diff($pid, $model)
    {
        $uri = "/gdc/projects/$pid/model/diff?includeDeprecated=true&includeGrain=true";
        $result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);

Severity: Minor
Found in src/ProjectModel.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

Function normalizeModel has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

    public function normalizeModel($model)
    {
        foreach ($model['projectModel']['datasets'] as &$d) {
            if (isset($d['dataset']['anchor']['attribute']['labels'])) {
                foreach ($d['dataset']['anchor']['attribute']['labels'] as &$l) {
Severity: Minor
Found in src/ProjectModel.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 diff has 65 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function diff($pid, $model)
    {
        $uri = "/gdc/projects/$pid/model/diff?includeDeprecated=true&includeGrain=true";
        $result = $this->client->post($uri, ['diffRequest' => ['targetModel' => $model]]);

Severity: Major
Found in src/ProjectModel.php - About 2 hrs to fix

    Function update has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
    Open

        public function update($pid, $model, $dryRun = false, $multivalueAttributes = [])
        {
            $model = $this->normalizeModel($model);
    
            $update = $this->diff($pid, $model);
    Severity: Minor
    Found in src/ProjectModel.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 dropDataSet has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        public function dropDataSet($pid, $dataSetName)
        {
            $dataSetId = Identifiers::getIdentifier($dataSetName);
            $model = $this->view($pid);
            if (isset($model['projectModel']['datasets'])) {
    Severity: Minor
    Found in src/ProjectModel.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 normalizeModel has 28 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function normalizeModel($model)
        {
            foreach ($model['projectModel']['datasets'] as &$d) {
                if (isset($d['dataset']['anchor']['attribute']['labels'])) {
                    foreach ($d['dataset']['anchor']['attribute']['labels'] as &$l) {
    Severity: Minor
    Found in src/ProjectModel.php - About 1 hr to fix

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

          public function update($pid, $model, $dryRun = false, $multivalueAttributes = [])
          {
              $model = $this->normalizeModel($model);
      
              $update = $this->diff($pid, $model);
      Severity: Minor
      Found in src/ProjectModel.php - About 1 hr to fix

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

            public function view($pid)
            {
                $uri = "/gdc/projects/$pid/model/view?includeDeprecated=true&includeGrain=true";
                $result = $this->client->get($uri);
        
        
        Severity: Minor
        Found in src/ProjectModel.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 updateMaqlWithMultivalueAttributes has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
        Open

            private function updateMaqlWithMultivalueAttributes(string $maql, array $multivalueAttributes): string
            {
                $lines = explode("\n", $maql);
        
                foreach ($multivalueAttributes as $fkName => $attribute) {
        Severity: Minor
        Found in src/ProjectModel.php - About 35 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 updateProject has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function updateProject($pid, $model, $dryRun = false)
            {
                // Get current GD model
                $gdModel = $this->view($pid);
                if (!isset($gdModel['projectModel']['datasets'])) {
        Severity: Minor
        Found in src/ProjectModel.php - About 25 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 updateDataSet has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
        Open

            public function updateDataSet($pid, $datasetModel, $dryRun = false)
            {
                $projectModel = $this->view($pid);
        
                if (!isset($projectModel['projectModel']['datasets'])) {
        Severity: Minor
        Found in src/ProjectModel.php - About 25 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

        There are no issues that match your filters.

        Category
        Status