File store.ts
has 561 lines of code (exceeds 250 allowed). Consider refactoring. Open
import Fuse from "fuse.js";
const log = utils.getLogger("locator");
import fetch from "node-fetch";
import * as utils from "../utils.js";
- Create a ticketCreate a ticket
Function locateStores
has 81 lines of code (exceeds 25 allowed). Consider refactoring. Open
async locateStores(location: any): Promise<InteractionReplyOptions> {
const count = 10; // number of "stores" to retrieve (error margin included for non-store results)
let googleBody: any;
try {
const res = await fetch(
- Create a ticketCreate a ticket
Function generateEventsEmbed
has 69 lines of code (exceeds 25 allowed). Consider refactoring. Open
generateEventsEmbed(
{ Address, Organization }: any,
response: any,
filters: any
): EmbedBuilder {
- Create a ticketCreate a ticket
Function fetchStores
has 62 lines of code (exceeds 25 allowed). Consider refactoring. Open
async fetchStores(longitude = -180, distance = 10) {
try {
if (longitude > 180 - distance) {
// fetchStores(longitude = 0, distance = 10) { // easier testing
// if (longitude > 20 - distance) {
- Create a ticketCreate a ticket
Function getEvents
has 53 lines of code (exceeds 25 allowed). Consider refactoring. Open
async getEvents(query: string): Promise<EmbedBuilder> {
// check if there are filters present
const filters: any = {};
let parameters = query.toLowerCase().split(" ");
if (parameters.length == 0) {
- Create a ticketCreate a ticket
Function generateStoreEmbed
has 48 lines of code (exceeds 25 allowed). Consider refactoring. Open
async generateStoreEmbed(
stores: any,
googleResult: any
): Promise<InteractionReplyOptions> {
const fields: any = [];
- Create a ticketCreate a ticket
Function getEvents
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
async getEvents(query: string): Promise<EmbedBuilder> {
// check if there are filters present
const filters: any = {};
let parameters = query.toLowerCase().split(" ");
if (parameters.length == 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 locateStores
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
async locateStores(location: any): Promise<InteractionReplyOptions> {
const count = 10; // number of "stores" to retrieve (error margin included for non-store results)
let googleBody: any;
try {
const res = await fetch(
- 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 generateStoreRequestBody
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
generateStoreRequestBody(geometry: any, count = 10) {
let requestBody = {
count,
filter_mass_markets: true,
language: "en-us",
- Create a ticketCreate a ticket
Function generateEventsEmbed
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
generateEventsEmbed(
{ Address, Organization }: any,
response: any,
filters: any
): EmbedBuilder {
- 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
Avoid too many return
statements within this function. Open
return {
embeds: [
await this.generateErrorEmbed(
null,
`Location \`${location}\` not found.`
- Create a ticketCreate a ticket