Showing 151 of 1,190 total issues
Function save
has 56 lines of code (exceeds 25 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;
}
Method mapFromDB
has 56 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function mapFromDB(array $data): array
{
$itemQuantities = explode('<', $data['quantities']);
$itemQuantities = array_map('intval', $itemQuantities);
$itemValue = explode('<', $data['values']);
File
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
class File extends AbstractEntity
{
/** Table name in database. */
public const TABLE_NAME = 'files';
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 = '';
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.'));
}
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);