FriendsOfPHP/pickle

View on GitHub

Showing 59 of 59 total issues

Function addFromString has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function addFromString(string $localname, string $contents): void
    {
        $localname = ltrim(str_replace(DIRECTORY_SEPARATOR, '/', $localname), '/');
        $this->createTempDir();
        $tempDir = $this->getTempDir();
Severity: Minor
Found in src/Base/Archive/InfozipZipper.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 cleanup has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function cleanup()
    {
        if (is_dir($this->tempDir)) {
            $iterator = new RecursiveIteratorIterator(
                new RecursiveDirectoryIterator(
Severity: Minor
Found in src/Base/Util/FileOps.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 getVersionFromHeader has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getVersionFromHeader()
    {
        $headers = glob($this->path . DIRECTORY_SEPARATOR . '*.h');
        $version_define = 'PHP_' . strtoupper($this->getSimpleName()) . '_VERSION';
        foreach ($headers as $header) {
Severity: Minor
Found in src/Package/PHP/Package.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 determine has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function determine($path, $remote)
    {
        if (substr($path, -4) == '.tgz' || substr($path, -7) == '.tar.gz') {
            return self::TGZ;
        }
Severity: Minor
Found in src/Package/Convey/Command/Type.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 getLog has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function getLog($hint = null)
    {
        $ret = [];

        foreach ($this->log as $item) {
Severity: Minor
Found in src/Base/Abstracts/Package/Build.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

Avoid too many return statements within this method.
Open

                return new SrcDir($path, $io);
Severity: Major
Found in src/Package/Convey/Command/Factory.php - About 30 mins to fix

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

            if ($json === false) {
                $error = error_get_last();
                $exception = null;
    
                if ($error !== null) {
    Severity: Minor
    Found in src/Package/Util/JSON/Loader.php and 1 other location - About 30 mins to fix
    src/Package/PHP/Util/XML/Loader.php on lines 68..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 90.

    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

            if ($xml === false) {
                $error = error_get_last();
                $exception = null;
    
                if ($error !== null) {
    Severity: Minor
    Found in src/Package/PHP/Util/XML/Loader.php and 1 other location - About 30 mins to fix
    src/Package/Util/JSON/Loader.php on lines 66..75

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

    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

    Avoid too many return statements within this method.
    Open

            return self::ANY;
    Severity: Major
    Found in src/Package/Convey/Command/Type.php - About 30 mins to fix

      Avoid too many return statements within this method.
      Open

              return new Any($path, $io);
      Severity: Major
      Found in src/Package/Convey/Command/Factory.php - About 30 mins to fix

        Avoid too many return statements within this method.
        Open

                    return self::PICKLE;
        Severity: Major
        Found in src/Package/Convey/Command/Type.php - About 30 mins to fix

          Function dump has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function dump(Interfaces\Package $package, $with_version = true)
              {
                  $data = [];
          
                  $data['name'] = $package->getPrettyName();
          Severity: Minor
          Found in src/Package/Util/Dumper.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 prepareConfigOpts has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function prepareConfigOpts()
              {
                  $configureOptions = '--enable-debug-pack';
                  foreach ($this->options as $name => $option) {
                      $decision = null;
          Severity: Minor
          Found in src/Package/PHP/Command/Build/Windows.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              private function create(bool $overwrite): void
              {
                  if (file_exists($this->path)) {
                      if ($overwrite === false) {
                          throw new RuntimeException("The ZIP archive {$this->path} already exists");
          Severity: Minor
          Found in src/Base/Archive/InfozipZipper.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 getMultiExtensionNames has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function getMultiExtensionNames()
              {
                  $info = $this->build->getInfo();
                  $ext_names = [$info['name']];
          
          
          Severity: Minor
          Found in src/Package/PHP/Command/Release/Windows/Binary.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 packLog has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function packLog($path)
              {
                  $zipperClass = Archive\Factory::getZipperClassName();
                  $zip = new $zipperClass($path, Interfaces\Archive\Zipper::FLAG_CREATE_OVERWRITE);
                  /** @var \Pickle\Base\Interfaces\Archive\Zipper $zip */
          Severity: Minor
          Found in src/Base/Abstracts/Package/Build.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 set has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public static function set($tmpDir, $create = false)
              {
                  if (!$create) {
                      if (!is_dir($tmpDir)) {
                          throw new Exception("Directory '{$tmpDir}' does not exist");
          Severity: Minor
          Found in src/Base/Util/TmpDir.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 create has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              public function create(array $args = [])
              {
                  $archBasename = $this->pkg->getSimpleName() . '-' . $this->pkg->getPrettyVersion();
          
                  /* Work around bug  #67417 [NEW]: ::compress modifies archive basename
          Severity: Minor
          Found in src/Package/PHP/Command/Release.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 getExtensionDirFromPhpInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
          Open

              protected function getExtensionDirFromPhpInfo($info)
              {
                  $extensionDir = '';
          
                  foreach ($info as $s) {
          Severity: Minor
          Found in src/Engine/PHP.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

          Severity
          Category
          Status
          Source
          Language