ahbeng/NUSMods

View on GitHub

Showing 212 of 556 total issues

Function theme has 30 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function theme(state: ThemeState = defaultThemeState, action: Actions): ThemeState {
  function setTheme(newTheme: string): ThemeState {
    // Update theme analytics info
    withTracker((tracker) => tracker.setCustomDimension(DIMENSIONS.theme, newTheme));

Severity: Minor
Found in website/src/reducers/theme.ts - About 1 hr to fix

    Function walkTree has 30 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

      function walkTree(fragment: PrereqTree): PrereqTree[] {
        if (typeof fragment === 'string') {
          // Parse a module code requirement as an nOf fragment.
          return walkTree({ nOf: [1, [fragment]] });
        }
    Severity: Minor
    Found in website/src/utils/planner.ts - About 1 hr to fix

      Function formatNumericWeeks has 30 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function formatNumericWeeks(unprocessedWeeks: NumericWeeks): string | null {
        // Ensure list of weeks are unique
        const weeks = unprocessedWeeks.filter(
          (value, index) => unprocessedWeeks.indexOf(value) === index,
        );
      Severity: Minor
      Found in website/src/utils/timetables.ts - About 1 hr to fix

        Function authenticate has 29 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export const authenticate = async (req: Request) => {
          const tokenProvided = req.headers.authorization || (req.body && req.body.SAMLResponse);
          if (!tokenProvided) {
            throw new Error(errors.noTokenSupplied);
          }
        Severity: Minor
        Found in website/src/serverless/nus-auth.ts - About 1 hr to fix

          Function make has 29 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          function make(props: Partial<Props> = {}) {
            const selectModuleColor = jest.fn();
            const onRemoveModule = jest.fn();
            const hideLessonInTimetable = jest.fn();
            const showLessonInTimetable = jest.fn();
          Severity: Minor
          Found in website/src/views/timetable/TimetableModuleTable.test.tsx - About 1 hr to fix

            Function getVersionMapping has 29 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            function getVersionMapping(browserCode, versionString) {
              const versions = _.get(browserslist, ['data', browserCode, 'versions']);
              if (!versions) {
                return undefined;
              }
            Severity: Minor
            Found in packages/browserslist-config-nusmods/scripts/helpers.js - About 1 hr to fix

              Function callApi has 29 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              async function callApi<Data>(endpoint: string, params: ApiParams): Promise<Data> {
                // 1. Construct request URL
                const url = new URL(endpoint, config.baseUrl);
                let response;
              
              
              Severity: Minor
              Found in scrapers/nus-v2/src/services/nus-api.ts - About 1 hr to fix

                Function calculateWeekRange has 29 lines of code (exceeds 25 allowed). Consider refactoring.
                Open

                export function calculateWeekRange(
                  lesson: RawLesson,
                  _semester: Semester,
                  weekRange: WeekRange,
                ): EventOption {
                Severity: Minor
                Found in website/src/utils/ical.ts - About 1 hr to fix

                  Function registerServiceWorker has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                  Open

                  export default function registerServiceWorker(store: Store<any, any>) {
                    const { serviceWorker } = navigator;
                    if (!serviceWorker) {
                      return;
                    }
                  Severity: Minor
                  Found in website/src/bootstrapping/service-worker-manager.ts - About 1 hr to fix

                    Function mapAttributes has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                    Open

                    export function mapAttributes(
                      attributes: ModuleAttributeEntry[],
                      logger: Logger,
                    ): NUSModuleAttributes | undefined {
                      const nusAttributes: NUSModuleAttributes = {};
                    Severity: Minor
                    Found in scrapers/nus-v2/src/tasks/GetSemesterData.ts - About 1 hr to fix

                      Function downloadIssues has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                      Open

                      async function downloadIssues() {
                        // eslint-disable-next-line import/no-dynamic-require, global-require
                        let venues = require(VENUES_PATH);
                      
                        const res = await axios.get(ISSUES_URL, {
                      Severity: Minor
                      Found in website/scripts/download-location-updates.js - About 1 hr to fix

                        Function DayHeader has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                        Open

                        const DayHeader: React.FC<Props> = (props) => {
                          const { forecast } = props;
                          const Icon = forecast ? getWeatherIcon(forecast) : null;
                        
                          const dates = castArray(props.date);
                        Severity: Minor
                        Found in website/src/views/today/DayHeader.tsx - About 1 hr to fix

                          Function BeforeLessonCard has 28 lines of code (exceeds 25 allowed). Consider refactoring.
                          Open

                          const BeforeLessonCard: React.FC<Props> = (props) => {
                            const { nextLesson, currentTime, marker } = props;
                            const nextLessonDate = getStartTimeAsDate(nextLesson);
                            const hoursTillNextLesson = differenceInHours(nextLessonDate, props.currentTime);
                          
                          
                          Severity: Minor
                          Found in website/src/views/today/BeforeLessonCard.tsx - About 1 hr to fix

                            Function getVersionMapping has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                            function getVersionMapping(browserCode, versionString) {
                              const versions = _.get(browserslist, ['data', browserCode, 'versions']);
                              if (!versions) {
                                return undefined;
                              }
                            Severity: Minor
                            Found in packages/browserslist-config-nusmods/scripts/helpers.js - 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 ModulesSelect has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const ModulesSelect: FC<Props> = ({
                              moduleCount,
                              placeholder,
                              disabled,
                              getFilteredModules,
                            Severity: Minor
                            Found in website/src/views/timetable/ModulesSelect.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 push has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                              push(path: string | LocationDescriptorObject, state?: HistoryLocationState) {
                                // Do not navigate if the path object matches
                                const nextPath = typeof path === 'string' ? path : createPath(path);
                                if (nextPath === createPath(this.history.location)) return;
                            
                            
                            Severity: Minor
                            Found in website/src/utils/HistoryDebouncer.ts - 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 GlobalSearchContainer has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                            const GlobalSearchContainer: FC = () => {
                              const dispatch = useDispatch();
                              useEffect(() => {
                                dispatch(fetchVenueList());
                              }, [dispatch]);
                            Severity: Minor
                            Found in website/src/views/layout/GlobalSearchContainer.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 computeUndoStacks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function computeUndoStacks<T extends { undoHistory: UndoHistoryState<T> }>(
                              state: UndoHistoryState<T> = {
                                past: [],
                                present: undefined, // Don't pretend to know the present
                                future: [],
                            Severity: Minor
                            Found in website/src/reducers/undoHistory.ts - 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 formatNumericWeeks has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function formatNumericWeeks(unprocessedWeeks: NumericWeeks): string | null {
                              // Ensure list of weeks are unique
                              const weeks = unprocessedWeeks.filter(
                                (value, index) => unprocessedWeeks.indexOf(value) === index,
                              );
                            Severity: Minor
                            Found in website/src/utils/timetables.ts - 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 conflictToText has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
                            Open

                            export function conflictToText(rootConflict: PrereqTree): string {
                              function walkSubtree(conflict: PrereqTree): string {
                                const text = walkTree(conflict);
                                if (typeof conflict === 'string') return text;
                                return `(${text})`;
                            Severity: Minor
                            Found in website/src/utils/planner.ts - 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

                            Severity
                            Category
                            Status
                            Source
                            Language