rugk/threema-msgapi-sdk-php

View on GitHub

Showing 39 of 299 total issues

Function receiveMessage has a Cognitive Complexity of 34 (exceeds 5 allowed). Consider refactoring.
Open

    public final function receiveMessage($threemaId,
                                         $messageId,
                                         $box,
                                         $nonce,
                                         $outputFolder = null,
Severity: Minor
Found in source/Threema/MsgApi/Helpers/E2EHelper.php - About 5 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

CryptTool has 35 functions (exceeds 20 allowed). Consider refactoring.
Open

abstract class CryptTool {
    const TYPE_SODIUM = 'sodium';
    const TYPE_SALT = 'salt';

    const FILE_NONCE = "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01";
Severity: Minor
Found in source/Threema/MsgApi/Tools/CryptTool.php - About 4 hrs to fix

Method receiveMessage has 68 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public final function receiveMessage($threemaId,
                                         $messageId,
                                         $box,
                                         $nonce,
                                         $outputFolder = null,
Severity: Major
Found in source/Threema/MsgApi/Helpers/E2EHelper.php - About 2 hrs to fix

File CryptTool.php has 272 lines of code (exceeds 250 allowed). Consider refactoring.
Open

<?php
/**
 * @author Threema GmbH
 * @copyright Copyright (c) 2015-2016 Threema GmbH
 */
Severity: Minor
Found in source/Threema/MsgApi/Tools/CryptTool.php - About 2 hrs to fix

Method decryptMessage has 57 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    final public function decryptMessage($box, $recipientPrivateKey, $senderPublicKey, $nonce) {

        $data = $this->openBox($box, $recipientPrivateKey, $senderPublicKey, $nonce);

        if (null === $data || strlen($data) == 0) {
Severity: Major
Found in source/Threema/MsgApi/Tools/CryptTool.php - About 2 hrs to fix

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

    private function createDefaultOptions(\Closure $progress = null) {
        $options = array(
            CURLOPT_RETURNTRANSFER => true
        );

Severity: Minor
Found in source/Threema/MsgApi/Connection.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 run has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public function run() {
        $found = null;
        $argumentLength = 0;

        //find the correct command by arguments and arguments count
Severity: Minor
Found in source/Threema/Console/Run.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 createDefaultOptions has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function createDefaultOptions(\Closure $progress = null) {
        $options = array(
            CURLOPT_RETURNTRANSFER => true
        );

Severity: Minor
Found in source/Threema/MsgApi/Connection.php - About 1 hr to fix

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

    protected function doRun() {
        $cryptTool = CryptTool::getInstance();

        $sendersThreemaId = $this->getArgumentThreemaId(self::argThreemaId);
        $id = $this->getArgumentThreemaId(self::argFrom);
Severity: Minor
Found in source/Threema/Console/Command/ReceiveMessage.php - About 1 hr to fix

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

    public function run() {
        $found = null;
        $argumentLength = 0;

        //find the correct command by arguments and arguments count
Severity: Minor
Found in source/Threema/Console/Run.php - About 1 hr to fix

Function __construct has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

    public function __construct($threemaId, $secret, $host = null, array $tlsOptions = null) {
        $this->threemaId = $threemaId;
        $this->secret = $secret;
        if ($host === null) {
            $host = 'https://msgapi.threema.ch';
Severity: Minor
Found in source/Threema/MsgApi/ConnectionSettings.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 sendFileMessage has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public final function sendFileMessage($threemaId, $filePath, $thumbnailPath = null) {
        //analyse the file
        $fileAnalyzeResult = FileAnalysisTool::analyse($filePath);

        if(null === $fileAnalyzeResult) {
Severity: Minor
Found in source/Threema/MsgApi/Helpers/E2EHelper.php - About 1 hr to fix

Method initFile has 27 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function initFile($fileHandle = null)
    {
        //check if file does already contain content
        if (filesize($this->file) != 0) {
            return true;
Severity: Minor
Found in source/Threema/MsgApi/PublicKeyStores/PhpFile.php - About 1 hr to fix

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

    public final function sendImageMessage($threemaId, $imagePath) {
        //analyse the file
        $fileAnalyzeResult = FileAnalysisTool::analyse($imagePath);

        if(null === $fileAnalyzeResult) {
Severity: Minor
Found in source/Threema/MsgApi/Helpers/E2EHelper.php - About 1 hr to fix

Method checkMac has 8 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public final function checkMac($threemaId, $gatewayId, $messageId, $date, $nonce, $box, $mac, $secret) {
Severity: Major
Found in source/Threema/MsgApi/Helpers/E2EHelper.php - About 1 hr to fix

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

    private function register($argumentKey, Base $command) {
        if(is_scalar($argumentKey)) {
            $argumentKey = array($argumentKey);
        }

Severity: Minor
Found in source/Threema/Console/Run.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

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

    private function call($path, array $curlOptions, array $parameters = null, \Closure $result = null) {
        $fullPath = new Url('', $this->setting->getHost());
        $fullPath->addPath($path);

        if (null !== $parameters && count($parameters)) {
Severity: Minor
Found in source/Threema/MsgApi/Connection.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

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

    final public function decryptMessage($box, $recipientPrivateKey, $senderPublicKey, $nonce) {

        $data = $this->openBox($box, $recipientPrivateKey, $senderPublicKey, $nonce);

        if (null === $data || strlen($data) == 0) {
Severity: Minor
Found in source/Threema/MsgApi/Tools/CryptTool.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

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

    public function stringCompare($str1, $str2)
    {
        if (function_exists('hash_equals')) {
            return hash_equals($str1, $str2);
        } else {
Severity: Minor
Found in source/Threema/MsgApi/Tools/CryptTool.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

Method encryptFileMessage has 7 arguments (exceeds 4 allowed). Consider refactoring.
Open

    final public function encryptFileMessage(UploadFileResult $uploadFileResult,
                                             EncryptResult $encryptResult,
                                             UploadFileResult $thumbnailUploadFileResult = null,
                                             FileAnalysisResult $fileAnalysisResult,
                                             $senderPrivateKey,
Severity: Major
Found in source/Threema/MsgApi/Tools/CryptTool.php - About 50 mins to fix
Severity
Category
Status
Source
Language