Showing 6,675 of 6,675 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
function createSubHost($db, $values){
$query = "SELECT NEXTVAL('intern_sub_host_seq')";
$id_result = pg_query($query);
// create new sub host
- Read upRead up
- Create a ticketCreate a ticket
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 106.
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
Function doTransition
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function doTransition($note = null)
{
// Make sure the transition makes sense based on the current state of the internship
$currStateName = $this->internship->getStateName();
- Read upRead up
- Create a ticketCreate a ticket
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 addOrder
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function addOrder($order)
{
if (is_array($order)) {
foreach ($order as $value) {
$this->addOrder($value);
- Read upRead up
- Create a ticketCreate a ticket
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 buildMessage
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
protected function buildMessage()
{
$this->tpl['NAME'] = $this->internship->getFullName();
$this->tpl['BANNER'] = $this->internship->banner;
$this->tpl['TERM'] = $this->term->getDescription();
- Read upRead up
- Create a ticketCreate a ticket
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 checkRequiredFields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function checkRequiredFields(Internship $i){
if (!$i->isSecondaryPart()) {
// Check the course subject
$courseSubj = $i->getSubject();
if (!isset($courseSubj) || $courseSubj == '' || $courseSubj->id == 0) {
- Read upRead up
- Create a ticketCreate a ticket
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 homogenize
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function homogenize(&$query)
{
$query_list = explode(',', $query);
$from[] = '/int\(\d+\)/iU';
- Read upRead up
- Create a ticketCreate a ticket
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 checkRequiredFields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function checkRequiredFields(Internship $i)
{
if (!$i->isSecondaryPart()) {
// Check the course subject
$courseSubj = $i->getSubject();
- Read upRead up
- Create a ticketCreate a ticket
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 checkRequiredFields
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public function checkRequiredFields(Internship $i){
if (!$i->isSecondaryPart()) {
// Check the course subject
$courseSubj = $i->getSubject();
if (!isset($courseSubj) || $courseSubj == '' || $courseSubj->id == 0){
- Read upRead up
- Create a ticketCreate a ticket
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 render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render(){
let list
if (this.state.currentFiles.length > 0) {
list = this.state.currentFiles.map(function(f){
let url = "index.php?module=intern&action=documentRest&type=affiliation&docId="+f.id+"&id="+this.props.affiliationId;
- Create a ticketCreate a ticket
Function render
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
render(){
let list
if (this.state.currentFiles.length > 0) {
list = this.state.currentFiles.map(function(f){
let url = "index.php?module=intern&action=documentRest&type=other&docId="+f.id+"&id="+this.props.internshipId;
- Create a ticketCreate a ticket
Method save
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function save(AffiliationAgreement $agreement)
{
if(!isset($agreement) || is_null($agreement)){
throw new \InvalidArgumentException('Missing agreement object');
}
- Create a ticketCreate a ticket
Method getSearchBox
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getSearchBox()
{
static $id_count = 0;
if ($id_count) {
- Create a ticketCreate a ticket
Method extractTableName
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function extractTableName($sql_value)
{
$temp = explode(' ', trim($sql_value));
if (!is_array($temp)) {
- Create a ticketCreate a ticket
Method dsn_array
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
function dsn_array()
{
static $dsn_array = null;
if (!empty($dsn_array)) {
- Create a ticketCreate a ticket
Method getDownLoad
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getDownLoad($docId, $type)
{
$target_file = $this->getPath($docId, $type);
if (!file_exists($target_file)) {
\NQ::simple('intern', \Intern\UI\NotifyUI::WARNING,
- Create a ticketCreate a ticket
Function onTermSave
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
onTermSave(newsemtype, newdescri, newcensusd, newavaild, newstartd, newendd, newugradover, newgradover, tcode) {
newcensusd = this.dateToTimestamp(newcensusd);
newavaild = this.dateToTimestamp(newavaild);
newstartd = this.dateToTimestamp(newstartd);
- Create a ticketCreate a ticket
Method post
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function post()
{
$cod = $_REQUEST['code'];
$descri = $_REQUEST['descr'];
$lev = $_REQUEST['level'];
- Create a ticketCreate a ticket
Method showStudentWarnings
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function showStudentWarnings()
{
// Check if we have a student object. If we don't, then bail immediately.
if(!isset($this->student)){
return;
- Create a ticketCreate a ticket
Identical blocks of code found in 2 locations. Consider refactoring. Open
errorNotice = <div style={{marginTop: "1em"}} className="alert alert-danger">
<p>{this.state.dataError}</p>
</div>
- Read upRead up
- Create a ticketCreate a ticket
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 59.
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
Method update
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update($return_affected = false)
{
PHPWS_DB::touchDB();
$table = $this->getTable(true);
- Create a ticketCreate a ticket