stingus/StingusJiraBundle

View on GitHub

Showing 23 of 23 total issues

Method execute has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $output->writeln('<info>Generate private / public keys for JIRA</info>');

        $countryQuestion = new Question('Enter the country name (eg. US): ');
Severity: Major
Found in Command/GenerateCertCommand.php - About 3 hrs to fix

    Method callbackAction has 42 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        public function callbackAction(Request $request): RedirectResponse
        {
            try {
                $oauthToken = null;
                if ($this->has('stingus_jira.oauth_token_manager')) {
    Severity: Minor
    Found in Controller/OauthController.php - About 1 hr to fix

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

              $organizationalUnitQuestion = new Question('Enter the organization unit name: ');
      Severity: Minor
      Found in Command/GenerateCertCommand.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

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

          public function connectAction(Request $request): RedirectResponse
          {
              $tokenId = $request->query->get('tokenId');
              $consumerKey = $request->query->get('consumerKey');
              $baseUrl = $request->query->get('baseUrl');
      Severity: Minor
      Found in Controller/OauthController.php - About 1 hr to fix

        Method getConfigTreeBuilder has 31 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function getConfigTreeBuilder()
            {
                $treeBuilder = new TreeBuilder();
                $rootNode = $treeBuilder->root('stingus_jira');
        
        
        Severity: Minor
        Found in DependencyInjection/Configuration.php - About 1 hr to fix

          Function callbackAction has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
          Open

              public function callbackAction(Request $request): RedirectResponse
              {
                  try {
                      $oauthToken = null;
                      if ($this->has('stingus_jira.oauth_token_manager')) {
          Severity: Minor
          Found in Controller/OauthController.php - About 55 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 variables with short names like $dn. Configured minimum length is 3.
          Open

                  $dn = [
          Severity: Minor
          Found in Command/GenerateCertCommand.php by phpmd

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

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

          Avoid variables with short names like $id. Configured minimum length is 3.
          Open

              public function setId($id): OauthTokenInterface;
          Severity: Minor
          Found in Model/OauthTokenInterface.php by phpmd

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

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

          Avoid variables with short names like $id. Configured minimum length is 3.
          Open

              protected $id;
          Severity: Minor
          Found in Model/AbstractOauthToken.php by phpmd

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

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

          Avoid variables with short names like $id. Configured minimum length is 3.
          Open

              public function setId($id): OauthTokenInterface
          Severity: Minor
          Found in Model/AbstractOauthToken.php by phpmd

          ShortVariable

          Since: 0.2

          Detects when a field, local, or parameter has a very short name.

          Example

          class Something {
              private $q = 15; // VIOLATION - Field
              public static function main( array $as ) { // VIOLATION - Formal
                  $r = 20 + $this->q; // VIOLATION - Local
                  for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
                      $r += $this->q;
                  }
              }
          }

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

          Missing class import via use statement (line '127', column '23').
          Open

                      ->add(new \DateInterval(sprintf('PT%sS', $responseTokens['oauth_expires_in'])));
          Severity: Minor
          Found in Oauth/Oauth.php by phpmd

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Missing class import via use statement (line '128', column '31').
          Open

                  $authExpiresAt = (new \DateTime())
          Severity: Minor
          Found in Oauth/Oauth.php by phpmd

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Missing class import via use statement (line '129', column '23').
          Open

                      ->add(new \DateInterval(sprintf('PT%sS', $responseTokens['oauth_authorization_expires_in'])));
          Severity: Minor
          Found in Oauth/Oauth.php by phpmd

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

          Remove error control operator '@' on line 112.
          Open

              protected function execute(InputInterface $input, OutputInterface $output)
              {
                  $output->writeln('<info>Generate private / public keys for JIRA</info>');
          
                  $countryQuestion = new Question('Enter the country name (eg. US): ');
          Severity: Minor
          Found in Command/GenerateCertCommand.php by phpmd

          ErrorControlOperator

          Error suppression should be avoided if possible as it doesn't just suppress the error, that you are trying to stop, but will also suppress errors that you didn't predict would ever occur. Consider changing error_reporting() level and/or setting up your own error handler.

          Example

          function foo($filePath) {
              $file = @fopen($filPath); // hides exceptions
              $key = @$array[$notExistingKey]; // assigns null to $key
          }

          Source http://phpmd.org/rules/cleancode.html#errorcontroloperator

          Missing class import via use statement (line '126', column '27').
          Open

                  $expiresAt = (new \DateTime())
          Severity: Minor
          Found in Oauth/Oauth.php by phpmd

          MissingImport

          Since: 2.7.0

          Importing all external classes in a file through use statements makes them clearly visible.

          Example

          function make() {
              return new \stdClass();
          }

          Source http://phpmd.org/rules/cleancode.html#MissingImport

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

              public function connectAction(Request $request): RedirectResponse
              {
                  $tokenId = $request->query->get('tokenId');
                  $consumerKey = $request->query->get('consumerKey');
                  $baseUrl = $request->query->get('baseUrl');
          Severity: Minor
          Found in Controller/OauthController.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

          The method connectAction uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
          Open

                      } else {
                          $this->addFlash(
                              'error',
                              $this->get('translator')->trans('jira.errors.general', [], 'StingusJiraBundle')
                          );
          Severity: Minor
          Found in Controller/OauthController.php by phpmd

          ElseExpression

          Since: 1.4.0

          An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($flag) {
                      // one branch
                  } else {
                      // another branch
                  }
              }
          }

          Source https://phpmd.org/rules/cleancode.html#elseexpression

          The method execute() has 106 lines of code. Current threshold is set to 100. Avoid really long methods.
          Open

              protected function execute(InputInterface $input, OutputInterface $output)
              {
                  $output->writeln('<info>Generate private / public keys for JIRA</info>');
          
                  $countryQuestion = new Question('Enter the country name (eg. US): ');
          Severity: Minor
          Found in Command/GenerateCertCommand.php by phpmd

          Avoid assigning values to variables in if clauses and the like (line '82', column '30').
          Open

              public function callbackAction(Request $request): RedirectResponse
              {
                  try {
                      $oauthToken = null;
                      if ($this->has('stingus_jira.oauth_token_manager')) {
          Severity: Minor
          Found in Controller/OauthController.php by phpmd

          IfStatementAssignment

          Since: 2.7.0

          Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($foo = 'bar') { // possible typo
                      // ...
                  }
                  if ($baz = 0) { // always false
                      // ...
                  }
              }
          }

          Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

          Avoid assigning values to variables in if clauses and the like (line '33', column '22').
          Open

              public function connectAction(Request $request): RedirectResponse
              {
                  $tokenId = $request->query->get('tokenId');
                  $consumerKey = $request->query->get('consumerKey');
                  $baseUrl = $request->query->get('baseUrl');
          Severity: Minor
          Found in Controller/OauthController.php by phpmd

          IfStatementAssignment

          Since: 2.7.0

          Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.

          Example

          class Foo
          {
              public function bar($flag)
              {
                  if ($foo = 'bar') { // possible typo
                      // ...
                  }
                  if ($baz = 0) { // always false
                      // ...
                  }
              }
          }

          Source http://phpmd.org/rules/cleancode.html#ifstatementassignment

          Severity
          Category
          Status
          Source
          Language