ahbeng/NUSMods

View on GitHub

Showing 212 of 556 total issues

Function SettingsContainer has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const SettingsContainer: React.FC<Props> = ({
  currentThemeId,
  colorScheme,
  betaTester,
  loadDisqusManually,
Severity: Minor
Found in website/src/views/settings/SettingsContainer.tsx - 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

Function fetchModule has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

async function fetchModule(moduleCode: string) {
  const fileName = `${moduleCode}.json`;

  let mod;

Severity: Minor
Found in export/src/data.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

Function prereq has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public prereq(): PrereqContext {
        let _localctx: PrereqContext = new PrereqContext(this._ctx, this.state);
        this.enterRule(_localctx, 32, NusModsParser.RULE_prereq);
        let _la: number;
        try {
Severity: Minor
Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.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

Function errorHandler has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

const errorHandler: Koa.Middleware<State> = async (ctx, next) => {
  try {
    await next();

    if (ctx.status === 404) {
Severity: Minor
Found in export/src/app.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

Function getAcadWeekInfo has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function getAcadWeekInfo(date: Date): AcadWeekInfo {
  const currentAcad = getAcadYear(date);
  const acadYear = currentAcad.year;
  const acadYearStartDate = getAcadYearStartDate(acadYear);

Severity: Minor
Found in packages/nusmoderator/src/academicCalendar.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

Function cohort_years has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

    public cohort_years(): Cohort_yearsContext {
        let _localctx: Cohort_yearsContext = new Cohort_yearsContext(this._ctx, this.state);
        this.enterRule(_localctx, 24, NusModsParser.RULE_cohort_years);
        let _la: number;
        try {
Severity: Minor
Found in scrapers/nus-v2/src/services/requisite-tree/antlr4/NusModsParser.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

Function PlannerModuleSelectComponent has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function PlannerModuleSelectComponent({
  id,
  className,
  rows,
  defaultValue,
Severity: Minor
Found in website/src/views/planner/PlannerModuleSelect.tsx - 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

Function NotificationText has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

}> = ({ useLineBreaks, round, now }) => {
  const isRoundOpen = now >= round.startDate;
  const timeFromNow = formatDistance(now, isRoundOpen ? round.endDate : round.startDate, {
    includeSeconds: true,
  });
Severity: Minor
Found in website/src/views/components/notfications/ModRegNotification.tsx - 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

Function moduleBank has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

function moduleBank(state: ModuleBank = defaultModuleBankState, action: Actions): ModuleBank {
  switch (action.type) {
    case SUCCESS_KEY(FETCH_MODULE_LIST):
      return {
        ...state,
Severity: Minor
Found in website/src/reducers/moduleBank.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

Function calculateWeekRange has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function calculateWeekRange(
  lesson: RawLesson,
  _semester: Semester,
  weekRange: WeekRange,
): EventOption {
Severity: Minor
Found in website/src/utils/ical.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

Function createSearchPredicate has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
Open

export function createSearchPredicate(
  searchTerm: string,
): (searchableModule: SearchableModule) => boolean {
  const searchRegexes = tokenize(searchTerm).map(regexify);

Severity: Minor
Found in website/src/utils/moduleSearch.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 undefined;
Severity: Major
Found in packages/browserslist-config-nusmods/scripts/helpers.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

            return;
    Severity: Major
    Found in scrapers/nus-v2/src/services/requisite-tree/parseString.ts - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

          return latestVersion;
      Severity: Major
      Found in packages/browserslist-config-nusmods/scripts/helpers.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

          if (acadWeekNumber <= lastWeekOfSpecialSem2) return special2;
        Severity: Major
        Found in packages/nusmoderator/src/academicCalendar.ts - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

            return <LoadingSpinner />;
          Severity: Major
          Found in website/src/views/modules/ModulePageContainer.tsx - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                return Thunderstorm;
            Severity: Major
            Found in website/src/views/components/icons/weather.ts - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                if (process.env.NODE_ENV === 'production' && process.env.CI) return 'preview';
              Severity: Major
              Found in website/webpack/webpack.parts.js - About 30 mins to fix

                Avoid too many return statements within this function.
                Open

                    return cleanedDesc.includes('light') ? Showers : Rain;
                Severity: Major
                Found in website/src/views/components/icons/weather.ts - About 30 mins to fix

                  Avoid too many return statements within this function.
                  Open

                    return 'development';
                  Severity: Major
                  Found in website/webpack/webpack.parts.js - About 30 mins to fix
                    Severity
                    Category
                    Status
                    Source
                    Language