rugk/threema-msgapi-sdk-php

View on GitHub

Showing 39 of 299 total issues

Function sendFileMessage has a Cognitive Complexity of 8 (exceeds 5 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 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 byJsonString has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public static final function byJsonString($string, array $requiredKeys = null) {
        $v = json_decode($string, true);
        if(null === $v || false === $v) {
            throw new Exception('invalid json string');
        }
Severity: Minor
Found in source/Threema/Core/AssocArray.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

Method __construct has 6 arguments (exceeds 4 allowed). Consider refactoring.
Open

    public function __construct($blobId, $thumbnailBlobId, $encryptionKey, $mimeType, $filename, $size) {
Severity: Minor
Found in source/Threema/MsgApi/Messages/FileMessage.php - About 45 mins to fix

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

    public function findPublicKey($threemaId) {
        $storeHandle = fopen($this->file, 'r');
        if(false === $storeHandle) {
            throw new Exception('could not open file '.$this->file);
        }
Severity: Minor
Found in source/Threema/MsgApi/PublicKeyStores/File.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 initFile has a Cognitive Complexity of 8 (exceeds 5 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 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

Method receiveMessage has 6 arguments (exceeds 4 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 45 mins to fix

Method encryptImageMessage has 5 arguments (exceeds 4 allowed). Consider refactoring.
Open

            UploadFileResult $uploadFileResult,
            EncryptResult $encryptResult,
            $senderPrivateKey,
            $recipientPublicKey,
            $nonce) {
Severity: Minor
Found in source/Threema/MsgApi/Tools/CryptTool.php - About 35 mins to fix

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

    public static function getInstance() {
        if(null === self::$instance) {
            foreach(array(
                function() {
                    return self::createInstance(self::TYPE_SODIUM);
Severity: Minor
Found in source/Threema/MsgApi/Tools/CryptTool.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 writeHelp has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public function writeHelp(\Closure $writer) {
        if(null !== $writer) {

            foreach($this->commands as $data) {
                if(is_scalar($data)) {
Severity: Minor
Found in source/Threema/Console/Run.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 analyse has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public static function analyse($file) {
        //check if file exists
        if(false === file_exists($file)) {
            return null;
        }
Severity: Minor
Found in source/Threema/MsgApi/Tools/FileAnalysisTool.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 'A temporary internal server error has occurred';
Severity: Major
Found in source/Threema/MsgApi/Commands/Results/SendSimpleResult.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'Unknown error';
Severity: Major
Found in source/Threema/MsgApi/Commands/Results/UploadFileResult.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'Unknown error';
Severity: Major
Found in source/Threema/MsgApi/Commands/Results/SendE2EResult.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'Unknown error';
Severity: Major
Found in source/Threema/MsgApi/Commands/Results/LookupIdResult.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'A temporary internal server error has occurred';
Severity: Major
Found in source/Threema/MsgApi/Commands/Results/SendE2EResult.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'Unknown error';
Severity: Major
Found in source/Threema/MsgApi/Commands/Results/SendSimpleResult.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return 'Message is too long';
Severity: Major
Found in source/Threema/MsgApi/Commands/Results/SendSimpleResult.php - About 30 mins to fix

Avoid too many return statements within this method.
Open

                return new FileMessage(
                    $values->getValue('b'),
                    $values->getValue('t'),
                    $values->getValue('k'),
                    $values->getValue('m'),
Severity: Major
Found in source/Threema/MsgApi/Tools/CryptTool.php - About 30 mins to fix

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

    public function fetchPublicKey($threemaId) {
        $publicKey = null;

        if (null !== $this->publicKeyStore) {
            $publicKey = $this->publicKeyStore->getPublicKey($threemaId);
Severity: Minor
Found in source/Threema/MsgApi/Connection.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