kiler129/TorrentGhost

View on GitHub

Showing 112 of 112 total issues

The class CookiesBag has 14 public methods. Consider refactoring CookiesBag to keep number of public methods under 10.
Open

class CookiesBag implements \ArrayAccess, \Iterator
{
    /**
     * @var array Internal array holding all cookies. Example: ['key' => ['kEy', 'vaLuE'], 'test' => ['TesT', 'abc']]
     */
Severity: Minor
Found in src/Http/CookiesBag.php by phpmd

TooManyPublicMethods

Since: 0.1

A class with too many public methods is probably a good suspect for refactoring, in order to reduce its complexity and find a way to have more fine grained objects.

By default it ignores methods starting with 'get' or 'set'.

Example

Source https://phpmd.org/rules/codesize.html#toomanypublicmethods

Function setParametersOnInstance has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

    private function setParametersOnInstance(ConfigurationInterface $instance)
    {
        $classReflection = new \ReflectionObject($instance);

        foreach ($this->instanceParameters as $paramName => $paramValue) {
Severity: Minor
Found in src/Configuration/ConfigurationFactory.php - About 3 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 parseFeedXml has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

    public function parseFeedXml($feed)
    {
        $feed = simplexml_load_string($feed);
        if ($feed === false) {
            $this->logger->error('RSS XML parsing failed in ' . $this->getName(), libxml_get_errors());
Severity: Minor
Found in src/Aggregator/RssAggregator.php - About 3 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

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

        if ($matchResult === false) {
            throw new RegexException(
                'Pattern was configured for ' . $this->getName() . ' aggregator to extract name',
                $this->configuration->getNameExtractPattern()
            );
Severity: Major
Found in src/Aggregator/AbstractAggregator.php and 1 other location - About 2 hrs to fix
src/Aggregator/AbstractAggregator.php on lines 167..182

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

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 ($matchResult === false) {
            throw new RegexException(
                'Pattern was configured for ' . $this->getName() . ' aggregator to extract link',
                $this->configuration->getLinkExtractPattern()
            );
Severity: Major
Found in src/Aggregator/AbstractAggregator.php and 1 other location - About 2 hrs to fix
src/Aggregator/AbstractAggregator.php on lines 135..150

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

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

    private function runMainLoop()
    {
        $except = null;

        while (true) {
Severity: Minor
Found in src/Application.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 parseFeedXml has 61 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function parseFeedXml($feed)
    {
        $feed = simplexml_load_string($feed);
        if ($feed === false) {
            $this->logger->error('RSS XML parsing failed in ' . $this->getName(), libxml_get_errors());
Severity: Major
Found in src/Aggregator/RssAggregator.php - About 2 hrs to fix

    Function matchDownloadLinks has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
    Open

        private function matchDownloadLinks($sourceName, array $links)
        {
            $this->logger->debug("Matching links from source $sourceName against all rules");
    
            $linksToDownload = [];
    Severity: Minor
    Found in src/Application.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

    Avoid excessively long variable names like $lastSuccessfulDownload. Keep variable name length under 20.
    Open

        private $lastSuccessfulDownload = -1;
    Severity: Minor
    Found in src/Aggregator/RssAggregator.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $nameNotContainsPattern. Keep variable name length under 20.
    Open

        private $nameNotContainsPattern;
    Severity: Minor
    Found in src/Rule/DownloadRule.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $configurationProvider. Keep variable name length under 20.
    Open

        public function __construct(ConfigurationProvider $configurationProvider, LoggerInterface $logger)
    Severity: Minor
    Found in src/Application.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $configurationProvider. Keep variable name length under 20.
    Open

                $configurationProvider = ConfigurationProvider::fromYamlFile($input->getOption('config'), $logger);
    Severity: Minor
    Found in src/Command/RunCommand.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $nameNotContainsPattern. Keep variable name length under 20.
    Open

        public function setNameNotContainsPattern($nameNotContainsPattern);
    Severity: Minor
    Found in src/Rule/RuleInterface.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $acceptUnsafeCertsFlag. Keep variable name length under 20.
    Open

            $acceptUnsafeCertsFlag = ($this->appConfig->isAcceptUnsafeCertificates()) ? 0 : 2; //I fucking love curl...
    Severity: Minor
    Found in src/Http/FetchJob.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $acceptUnsafeCertificates. Keep variable name length under 20.
    Open

        private $acceptUnsafeCertificates = false;

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $nameNotContainsPattern. Keep variable name length under 20.
    Open

        public function setNameNotContainsPattern($nameNotContainsPattern)
    Severity: Minor
    Found in src/Rule/DownloadRule.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $configurationProvider. Keep variable name length under 20.
    Open

        private $configurationProvider;
    Severity: Minor
    Found in src/Application.php by phpmd

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

    Avoid excessively long variable names like $configurationProvider. Keep variable name length under 20.
    Open

        public function __construct(ConfigurationProvider $configurationProvider)

    LongVariable

    Since: 0.2

    Detects when a field, formal or local variable is declared with a long name.

    Example

    class Something {
        protected $reallyLongIntName = -3; // VIOLATION - Field
        public static function main( array $interestingArgumentsList[] ) { // VIOLATION - Formal
            $otherReallyLongName = -5; // VIOLATION - Local
            for ($interestingIntIndex = 0; // VIOLATION - For
                 $interestingIntIndex < 10;
                 $interestingIntIndex++ ) {
            }
        }
    }

    Source https://phpmd.org/rules/naming.html#longvariable

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

        private function setParametersOnInstance(ConfigurationInterface $instance)
        {
            $classReflection = new \ReflectionObject($instance);
    
            foreach ($this->instanceParameters as $paramName => $paramValue) {
    Severity: Minor
    Found in src/Configuration/ConfigurationFactory.php - About 1 hr to fix

      Method runMainLoop has 34 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          private function runMainLoop()
          {
              $except = null;
      
              while (true) {
      Severity: Minor
      Found in src/Application.php - About 1 hr to fix
        Severity
        Category
        Status
        Source
        Language