File s3.class.php
has 1756 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/*
* Copyright 2010-2011 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
Function authenticate
has a Cognitive Complexity of 85 (exceeds 5 allowed). Consider refactoring. Open
public function authenticate($bucket, $opt = null, $location = null, $redirects = 0, $nothing = null)
{
/*
* Overriding or extending this class? You can pass the following "magic" keys into $opt.
*
- Read upRead up
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 authenticate
has 293 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function authenticate($bucket, $opt = null, $location = null, $redirects = 0, $nothing = null)
{
/*
* Overriding or extending this class? You can pass the following "magic" keys into $opt.
*
AmazonS3
has 67 functions (exceeds 20 allowed). Consider refactoring. Open
class AmazonS3 extends CFRuntime
{
/*%******************************************************************************************%*/
// CLASS CONSTANTS
Function create_mpu_object
has a Cognitive Complexity of 39 (exceeds 5 allowed). Consider refactoring. Open
public function create_mpu_object($bucket, $filename, $opt = null)
{
if ($this->use_batch_flow)
{
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
- Read upRead up
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 create_mpu_object
has 111 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_mpu_object($bucket, $filename, $opt = null)
{
if ($this->use_batch_flow)
{
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
Method copy_object
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function copy_object($source, $dest, $opt = null)
{
if (!$opt) $opt = array();
$batch = array();
Function copy_object
has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring. Open
public function copy_object($source, $dest, $opt = null)
{
if (!$opt) $opt = array();
$batch = array();
- Read upRead up
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 delete_all_object_versions
has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring. Open
public function delete_all_object_versions($bucket, $pcre = null)
{
if ($this->use_batch_flow)
{
// @codeCoverageIgnoreStart
- Read upRead up
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 delete_all_object_versions
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function delete_all_object_versions($bucket, $pcre = null)
{
if ($this->use_batch_flow)
{
// @codeCoverageIgnoreStart
Consider simplifying this complex logical expression. Open
if (
($bucket === null || $bucket === false) || // Must not be null or false
preg_match('/[^(a-z0-9\-\.)]/', $bucket) || // Must be in the lowercase Roman alphabet, period or hyphen
!preg_match('/^([a-z]|\d)/', $bucket) || // Must start with a number or letter
!(strlen($bucket) >= 3 && strlen($bucket) <= 63) || // Must be between 3 and 63 characters long
Method get_object_list
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_object_list($bucket, $opt = null)
{
if ($this->use_batch_flow)
{
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
Method enable_logging
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function enable_logging($bucket, $target_bucket, $target_prefix, $opt = null)
{
// Add this to our request
if (!$opt) $opt = array();
$opt['verb'] = 'PUT';
Method get_object_metadata
has 46 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_object_metadata($bucket, $filename, $opt = null)
{
$batch = new CFBatchRequest();
$this->batch($batch)->get_object_acl($bucket, $filename); // Get ACL info
$this->batch($batch)->get_object_headers($bucket, $filename); // Get content-type
Function enable_logging
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function enable_logging($bucket, $target_bucket, $target_prefix, $opt = null)
{
// Add this to our request
if (!$opt) $opt = array();
$opt['verb'] = 'PUT';
- Read upRead up
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 complete_multipart_upload
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function complete_multipart_upload($bucket, $filename, $upload_id, $parts, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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 complete_multipart_upload
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function complete_multipart_upload($bucket, $filename, $upload_id, $parts, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
Method generate_access_policy
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function generate_access_policy($canonical_id, $canonical_name, $users)
{
$xml = simplexml_load_string($this->base_acp_xml);
$owner = $xml->addChild('Owner');
$owner->addChild('ID', $canonical_id);
Method create_bucket
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_bucket($bucket, $region, $acl = self::ACL_PRIVATE, $opt = null)
{
// If the bucket contains uppercase letters...
if (preg_match('/[A-Z]/', $bucket))
{
Method copy_part
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function copy_part($source, $dest, $upload_id, $part_number, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
Method abort_multipart_uploads_by_date
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function abort_multipart_uploads_by_date($bucket, $when = null)
{
if ($this->use_batch_flow)
{
// @codeCoverageIgnoreStart
Method initiate_multipart_upload
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function initiate_multipart_upload($bucket, $filename, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
Method create_object
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create_object($bucket, $filename, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
Function get_object_list
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function get_object_list($bucket, $opt = null)
{
if ($this->use_batch_flow)
{
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
- Read upRead up
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 set_object_acl
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function set_object_acl($bucket, $filename, $acl = self::ACL_PRIVATE, $opt = null)
{
// Add this to our request
if (!$opt) $opt = array();
$opt['verb'] = 'PUT';
Method get_object
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_object($bucket, $filename, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
Method get_bucket_filesize
has 26 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function get_bucket_filesize($bucket, $friendly_format = false)
{
if ($this->use_batch_flow)
{
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
Consider simplifying this complex logical expression. Open
if (
($bucket === null || $bucket === false) || // Must not be null or false
preg_match('/[^(a-z0-9_\-\.)]/i', $bucket) || // Must be in the Roman alphabet, period, hyphen or underscore
!preg_match('/^([a-z]|\d)/i', $bucket) || // Must start with a number or letter
!(strlen($bucket) >= 3 && strlen($bucket) <= 255) || // Must be between 3 and 255 characters long
Function get_object
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function get_object($bucket, $filename, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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 generate_access_policy
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring. Open
public function generate_access_policy($canonical_id, $canonical_name, $users)
{
$xml = simplexml_load_string($this->base_acp_xml);
$owner = $xml->addChild('Owner');
$owner->addChild('ID', $canonical_id);
- Read upRead up
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_object_acl
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function set_object_acl($bucket, $filename, $acl = self::ACL_PRIVATE, $opt = null)
{
// Add this to our request
if (!$opt) $opt = array();
$opt['verb'] = 'PUT';
- Read upRead up
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 initiate_multipart_upload
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function initiate_multipart_upload($bucket, $filename, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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 copy_part
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function copy_part($source, $dest, $upload_id, $part_number, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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_object
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function create_object($bucket, $filename, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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
Consider simplifying this complex logical expression. Open
if (
strtolower($header_key) === 'content-md5' ||
strtolower($header_key) === 'content-type' ||
strtolower($header_key) === 'date' ||
(strtolower($header_key) === 'expires' && isset($opt['preauth']) && (integer) $opt['preauth'] > 0)
Method complete_multipart_upload
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function complete_multipart_upload($bucket, $filename, $upload_id, $parts, $opt = null)
Method authenticate
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function authenticate($bucket, $opt = null, $location = null, $redirects = 0, $nothing = null)
Method copy_part
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function copy_part($source, $dest, $upload_id, $part_number, $opt = null)
Function create_bucket
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
public function create_bucket($bucket, $region, $acl = self::ACL_PRIVATE, $opt = null)
{
// If the bucket contains uppercase letters...
if (preg_match('/[A-Z]/', $bucket))
{
- Read upRead up
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 $request->prep_request();
Avoid too many return
statements within this method. Open
return $this->request_url;
Avoid too many return
statements within this method. Open
return $data;
Avoid too many return
statements within this method. Open
return $handle;
Function get_bucket_filesize
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_bucket_filesize($bucket, $friendly_format = false)
{
if ($this->use_batch_flow)
{
throw new S3_Exception(__FUNCTION__ . '() cannot be batch requested');
- Read upRead up
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 upload_part
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function upload_part($bucket, $filename, $upload_id, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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 get_object_url
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function get_object_url($bucket, $filename, $preauth = 0, $opt = null)
{
// Add this to our request
if (!$opt) $opt = array();
$opt['verb'] = isset($opt['method']) ? $opt['method'] : 'GET';
- Read upRead up
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
foreach ($opt['users'] as $user)
{
$grant = $TargetGrants->addChild('Grant');
$grantee = $grant->addChild('Grantee');
- Read upRead up
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 252.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
foreach ($users as $user)
{
$grant = $acl->addChild('Grant');
$grantee = $grant->addChild('Grantee');
- Read upRead up
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 252.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function enable_versioning($bucket, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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 203.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function disable_versioning($bucket, $opt = null)
{
if (!$opt) $opt = array();
// Add this to our request
- Read upRead up
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 203.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
if ($this->use_cache_flow)
{
// Generate an identifier specific to this particular set of arguments.
$cache_id = $this->key . '_' . get_class($this) . '_' . $bucket . '_' . sha1(serialize($method_arguments));
- Read upRead up
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 173.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
public function cache_callback($bucket, $opt = null, $location = null, $redirects = 0)
{
// Disable the cache flow since it's already been handled.
$this->use_cache_flow = false;
- Read upRead up
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 103.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76