shootismoke/webapp

View on GitHub

Showing 14 of 59 total issues

Function CityTemplate has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

export default function CityTemplate(props: CityProps): React.ReactElement {
    const { frequency, setFrequency } = useContext(FrequencyContext);
    const { city, cities } = props;
    const [api, setApi] = useState<Api | undefined>(city.api);
    const [error, setError] = useState<Error>();
Severity: Minor
Found in src/frontend/components/layout/city.tsx - About 3 hrs to fix

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

File SearchBar.tsx has 262 lines of code (exceeds 250 allowed). Consider refactoring.
Open

/**
 * This file is part of Sh**t! I Smoke.
 *
 * Copyright (C) 2018-2021  Marcelo S. Coelho, Amaury M.
 *
Severity: Minor
Found in src/frontend/components/SearchBar/SearchBar.tsx - About 2 hrs to fix

    Function SearchBar has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
    Open

    export function SearchBar(props: SearchBarProps): React.ReactElement {
        const {
            cities,
            className,
            placeholder = 'Search a city or address',
    Severity: Minor
    Found in src/frontend/components/SearchBar/SearchBar.tsx - About 1 hr to fix

    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 handleReceipts has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
    Open

    export async function handleReceipts(
        expo: Expo,
        receiptIds: string[],
        onOk: (_receiptId: ExpoPushReceiptId, _receipt: ExpoPushReceipt) => void,
        onError: (_receiptId: ExpoPushReceiptId, _receipt: ExpoPushReceipt) => void
    Severity: Minor
    Found in src/backend/reports/expo/expo.ts - About 55 mins to fix

    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 emailForUser has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
    Open

    async function emailForUser(
        user: MongoUser,
        cities: City[]
    ): Promise<CreateMessageOpts> {
        if (!user.emailReport) {
    Severity: Minor
    Found in src/backend/reports/email/main.ts - About 35 mins to fix

    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 false;
    Severity: Major
    Found in src/frontend/util/doNotTrack.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

              return [
                  <HealthTip imgAlt="warning" imgSrc={warning} key={1}>
                      <p className="type-400 md:type-500">
                          <span className="text-orange">Health alert:</span> Stop
                          outdoor activities and move all activities indoors.
      Severity: Major
      Found in src/frontend/components/PollutantSection/HealthSection/HealthSection.tsx - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

                return [
                    `<span style="color: #f2934e;">Health alert:</span> everyone may experience more serious health effects.`,
                    `Everyone should <span style="color: #f2934e;"> reduce outdoor activities,</span> especially vulnerable people.`,
                ];
        Severity: Major
        Found in src/backend/reports/email/tips.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

                  return [
                      <HealthTip imgAlt="warning" imgSrc={warning} key={1}>
                          <p className="type-400 md:type-500">
                              <span className="text-orange">Health alert:</span> everyone
                              may experience more serious health effects.
          Severity: Major
          Found in src/frontend/components/PollutantSection/HealthSection/HealthSection.tsx - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                    return [
                        `<span style="color: #f2934e;">Health alert:</span> Stop outdoor activities and move all activities indoors.`,
                        `If it is necessary to go out, please <span style="color: #f2934e;">wear a mask</span>.`,
                    ];
            Severity: Major
            Found in src/backend/reports/email/tips.ts - About 30 mins to fix

              Function tips has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function tips(aqi: number): string[] {
                  if (aqi <= 50) {
                      return [
                          `Air quality is considered <span style="color: #f2934e;">satisfactory</span>, and air pollution poses little or no risk.`,
                          `<span style="color: #f2934e;">Enjoy</span> your usual outdoor activities.`,
              Severity: Minor
              Found in src/backend/reports/email/tips.ts - About 25 mins to fix

              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 tips has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              function tips(aqi: number): React.ReactElement[] {
                  if (aqi <= 50) {
                      return [
                          <HealthTip imgAlt="happy" imgSrc={happy} key={1}>
                              <p className="type-400 md:type-500">
              Severity: Minor
              Found in src/frontend/components/PollutantSection/HealthSection/HealthSection.tsx - About 25 mins to fix

              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 Cigarettes has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function Cigarettes(props: CigarettesProps): React.ReactElement {
                  const { cigarettes } = props;
              
                  const cigaretteConfig = getCigaretteConfig(cigarettes);
              
              
              Severity: Minor
              Found in src/frontend/components/Cigarettes/Cigarettes.tsx - About 25 mins to fix

              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 Carousel has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
              Open

              export function Carousel(props: CarouselProps): React.ReactElement {
                  const {
                      children,
                      className,
                      innerClassName,
              Severity: Minor
              Found in src/frontend/components/Carousel/Carousel.tsx - About 25 mins to fix

              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

              Severity
              Category
              Status
              Source
              Language