Showing 1,189 of 1,190 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
function deleteCategory(navn, id) {
if (confirm("Vil du slette katagorien '" + navn + "'?")) {
$("loading").style.visibility = "";
xHttp.request("/admin/categories/" + id + "/", deleteCallback, "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
Method siteMap
has 42 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function siteMap(Request $request): Response
{
app(DbService::class)->addLoadedTable('bind', 'kat', 'sider', 'special', 'maerke', 'krav');
$response = new Response('', Response::HTTP_OK, ['Content-Type' => 'text/xml;charset=utf-8']);
$response = $this->cachedResponse($response);
Method addressSave
has 41 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function addressSave(Request $request, int $id, string $checkId): Response
{
$invoice = app(OrmService::class)->getOne(Invoice::class, $id);
if ($redirect = $this->checkStatus($id, $checkId, $invoice)) {
return $redirect;
Method inventory
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function inventory(Request $request): Response
{
app(DbService::class)->addLoadedTable('bind', 'kat', 'krav', 'maerke', 'sider');
$response = $this->cachedResponse();
if ($response->isNotModified($request)) {
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (confirm("Vil du fjerne '" + navn + "' som tilbehor?")) {
$("loading").style.visibility = "";
xHttp.request("/admin/page/" + pageId + "/accessories/" + accessoryId + "/", deleteCallback, "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 67.
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 (confirm("Vil du fjerne siden fra '" + navn + "'?")) {
$("loading").style.visibility = "";
xHttp.request("/admin/page/" + id + "/categories/" + categoryId + "/", callback, "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 67.
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 rss
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function rss(Request $request): Response
{
$db = app(DbService::class);
$db->addLoadedTable('bind', 'files', 'kat', 'maerke', 'sider');
- 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 __construct
has 38 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function __construct(array $data = [])
{
$this->setItemData(strval($data['item_data'] ?? '[]'))
->setHasShippingAddress(boolval($data['has_shipping_address'] ?? false))
->setTimeStamp(intval($data['timestamp'] ?? time()))
The class Invoice has 38 fields. Consider redesigning Invoice to keep the number of fields under 15. Open
class Invoice extends AbstractEntity
{
/** Table name in database. */
public const TABLE_NAME = 'fakturas';
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Function updateOrientation
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
function updateOrientation(move) {
orientation += orientation < 10 ? move : -move;
switch (orientation) {
case 1:
rotate = 0;
Method terms
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function terms(Request $request, int $id, string $checkId): Response
{
$invoice = app(OrmService::class)->getOne(Invoice::class, $id);
if ($redirect = $this->checkStatus($id, $checkId, $invoice)) {
return $redirect;
Method folderRename
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function folderRename(Request $request): JsonResponse
{
$path = $request->getRequestString('path') ?? '';
$name = $request->getRequestString('name') ?? '';
$name = $this->fileService->cleanFileName($name);
Method purifyHTML
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
function purifyHTML(string $html): string
{
$config = HTMLPurifier_Config::createDefault();
/** @var Application */
$app = app();
Method index
has 36 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function index(Request $request, ?int $id = null): Response
{
$selectedId = intval($request->cookies->get('activekat', -1));
$openCategories = explode('<', strval($request->cookies->get('openkat', '')));
$openCategories = array_map('intval', $openCategories);
Function send
has 35 lines of code (exceeds 25 allowed). Consider refactoring. Open
function send() {
status("Klargøre data.");
totals = [];
uploads = [];
Method update
has 35 lines of code (exceeds 25 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);
Similar blocks of code found in 3 locations. Consider refactoring. Open
public function sendReminder(Request $request, int $id): JsonResponse
{
$invoice = app(OrmService::class)->getOne(Invoice::class, $id);
if (!$invoice) {
throw new InvalidInput(_('Invoice not found.'), Response::HTTP_NOT_FOUND);
- 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 108.
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
public function annulPayment(Request $request, int $id): JsonResponse
{
$invoice = app(OrmService::class)->getOne(Invoice::class, $id);
if (!$invoice) {
throw new InvalidInput(_('Invoice not found.'), Response::HTTP_NOT_FOUND);
- 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 108.
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
public function capturePayment(Request $request, int $id): JsonResponse
{
$invoice = app(OrmService::class)->getOne(Invoice::class, $id);
if (!$invoice) {
throw new InvalidInput(_('Invoice not found.'), Response::HTTP_NOT_FOUND);
- 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 108.
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 listInsertRowCallback
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
function listInsertRowCallback(data) {
if (!genericCallback(data)) {
return;
}