Showing 1,189 of 1,190 total issues
Function save
has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring. Open
function save(id = null, type = null) {
if (type === "cancel" && !confirm("Are you sure you want to cancel this Invoice?")) {
return false;
}
- 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 update
has 52 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function update(Request $request, int $id): JsonResponse
{
$orm = app(OrmService::class);
$category = $orm->getOne(Category::class, $id);
Method cleanAddressData
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function cleanAddressData(array $data): array
{
$data = [
'name' => $data['name'] ?? '',
'attn' => $data['attn'] ?? '',
Method getInvalid
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getInvalid(): array
{
$invalid = [];
if (!$this->hasValidEmail()) {
Method generateFilterInvoiceBySelection
has 50 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generateFilterInvoiceBySelection(InvoiceFilter $selected, User $user): string
{
if ($selected->id) {
return 'WHERE `id` = ' . $selected->id;
}
Consider simplifying this complex logical expression. Open
if (!$data['shipping_address2']
&& ($data['shipping_phone'] === $data['phone1'] || $data['shipping_phone'] === $data['phone2'])
&& $data['shipping_name'] === $data['name']
&& $data['shipping_attn'] === $data['attn']
&& $data['shipping_address'] === $data['address']
Method create
has 49 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function create(Request $request): RedirectResponse
{
$fullname = $request->get('fullname');
$name = $request->getRequestString('name') ?? '';
$password = $request->getRequestString('password') ?? '';
Function prisUpdate
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
function prisUpdate() {
invoiceLines = [];
invoiceAmount = 0;
var titles = document.getElementsByName("product");
- 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 getPageData
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
protected function getPageData(string $type, Page $page): array
{
$categories = $page->getCategories();
$paths = [];
$isVisible = false;
- 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 results
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function results(Request $request): Response
{
if ($response = $this->checkSearchable($request)) {
return $response;
}
Function prisUpdate
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
function prisUpdate() {
invoiceLines = [];
invoiceAmount = 0;
var titles = document.getElementsByName("product");
Method fileRename
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fileRename(Request $request, int $id): JsonResponse
{
try {
$file = app(OrmService::class)->getOne(File::class, $id);
if (!$file) {
Method send
has 45 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function send(Request $request): Response
{
$rawCart = $request->get('cart');
if (!is_string($rawCart)) {
$rawCart = '';
Similar blocks of code found in 3 locations. Consider refactoring. Open
var imageTileContextMenu = [{
"name": "Åbne",
"className": "picture",
callback(e) {
var id = getContextMenuTarget(e.target, "imagetile").id.match(/[0-9]+/g)[0];
- 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 71.
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 3 locations. Consider refactoring. Open
imageTileContextMenu.push({
"name": "Indsæt link",
"className": "link",
callback(e) {
var id = getContextMenuTarget(e.target, "imagetile").id.match(/[0-9]+/g)[0];
- 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 71.
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 3 locations. Consider refactoring. Open
{
"name": "Åbne",
"className": "eye",
callback(e) {
var id = getContextMenuTarget(e.target, "filetile").id.match(/[0-9]+/g)[0];
- 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 71.
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 update
has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring. Open
public function update(Request $request, int $id): JsonResponse
{
$user = $request->user();
if (!$user || (!$user->hasAccess(User::ADMINISTRATOR) && $user->getId() !== $id)) {
throw new InvalidInput(_('You do not have permission to edit users.'), Response::HTTP_FORBIDDEN);
- 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 send
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function send(): void
{
if ($this->sent) {
throw new Exception(_('The newsletter has already been sent.'));
}
Method sendInvoice
has 43 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function sendInvoice(Invoice $invoice): void
{
if (!$invoice->hasValidEmail()) {
throw new InvalidInput(_('Email is not valid.'));
}
Similar blocks of code found in 2 locations. Consider refactoring. Open
function deletePage(navn, id) {
if (confirm("Vil du slette '" + navn + "'?")) {
$("loading").style.visibility = "";
xHttp.request("/admin/page/" + id + "/", removeElementByClass, "DELETE");
}
- 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 69.
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