wongjiahau/ttap-web

View on GitHub

Showing 211 of 211 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

    x.SubjectCode === y.SubjectCode &&
    x.Type === y.Type &&
    x.Day === y.Day &&
    x.TimePeriod === y.TimePeriod
Severity: Major
Found in src/ts/permutator/generalizeSlot.ts and 1 other location - About 1 hr to fix
src/ts/redux/actions/saveTimetable/saveTimetableAsTextFile.ts on lines 38..41

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 2 locations. Consider refactoring.
Open

        x.Uid !== y.Uid &&
        x.SubjectCode === y.SubjectCode &&
        x.Type === y.Type &&
        x.Day === y.Day &&
src/ts/permutator/generalizeSlot.ts on lines 51..54

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 61.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Function GenerateNewState has 32 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  protected GenerateNewState(state: IMasterState): IMasterState {
    const newClickedTimeConstraint =
      state.SetTimeConstraintState.ClickedTimeConstraint.slice();
    newClickedTimeConstraint[this.clickedBox.Day] ^= this.clickedBox.TimePeriod;
    const newUidsOfClickedBox =
Severity: Minor
Found in src/ts/redux/actions/defilterTimetable.ts - About 1 hr to fix

    Function mapDispatchToProps has 32 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    const mapDispatchToProps = (dispatch: any): ITimetableListViewDispatchProps => {
      const triggerfulDispatch = (action: MasterStateAction) => {
        dispatch(action);
        dispatch(new FindAlternativeSlotsOfCurrentSlots());
      };
    Severity: Minor
    Found in src/ts/redux/containers/timetableListContainer.ts - About 1 hr to fix

      Function SelectSubject has 32 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

      export function SelectSubject(
        subjectToBeSelected: Subject,
        allSubjects: Subject[],
        state: IMasterState
      ): IMasterState {
      Severity: Minor
      Found in src/ts/redux/actions/toggleSubjectSelection.ts - About 1 hr to fix

        Function ParseRawSlotToSubject has 32 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

        export function ParseRawSlotToSubject(slots: RawSlot[]): Subject[] {
          const result = Array<Subject>();
          const dic = new Array<IKeyValue<string, RawSlot[]>>();
          slots
            .filter((x) => IsReasonable(x) && IsParsable(x))
        Severity: Minor
        Found in src/ts/parser/parseRawSlotToSubject.ts - About 1 hr to fix

          Function CreateEvent has 32 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

          export function CreateEvent(slot: RawSlot, semesterStartDate: Date) {
            const semStartDate = new Date(semesterStartDate.getTime());
            if (semStartDate.getDay() !== 1) {
              throw new Error(
                "Expected semesterStartDay to be Monday but was " +
          Severity: Minor
          Found in src/ts/redux/actions/saveTimetable/saveTimetableAsGoogleCalendar.ts - About 1 hr to fix

            Function correctBounds has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
            Open

            function correctBounds(layout, bounds) {
              var collidesWith = getStatics(layout);
              for (var _i4 = 0, len = layout.length; _i4 < len; _i4++) {
                var l = layout[_i4];
                // Overflows right
            Severity: Minor
            Found in src/ts/modified_node_modules/react-grid-layout/build/utils.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 GenerateSlotAndDayLayouts has 31 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

            export function GenerateSlotAndDayLayouts(
              rawSlots: ISlotViewModel[],
              xOffset: number,
              yOffset: number
            ): [ReactGridLayout.Layout[], ReactGridLayout.Layout[]] {
            Severity: Minor
            Found in src/ts/react/timetableView/generateSlotAndDayLayouts.ts - About 1 hr to fix

              Function GetTimeRow has 31 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

                private GetTimeRow(): JSX.Element[] {
                  const divStyle: React.CSSProperties = {
                    borderBottom: "1px solid",
                    borderRight: "1px solid",
                    height: "20.5px",
              Severity: Minor
              Found in src/ts/react/timetableView/skeleton.tsx - About 1 hr to fix

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

                  ReactGridLayout.prototype.placeholder = function placeholder() {
                    var activeDrag = this.state.activeDrag;
                
                    if (!activeDrag) return null;
                    var _props3 = this.props,

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

                    const slotViews = slots.map((x, index) => {
                      return (
                        // "s" means "Slot"
                        <div key={"s" + index}>
                          <SlotView
                  Severity: Minor
                  Found in src/ts/react/timetableView/generateSlotViewsAndDayColumn.tsx - About 1 hr to fix

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

                    export function GeneralizeSlot(originalSlots: RawSlot[]): RawSlot[] {
                      const slots = originalSlots.map(clone) as IRawSlot[];
                      const results = new Array<RawSlot>();
                      results.push(slots[0]);
                      let generalized: boolean;
                    Severity: Minor
                    Found in src/ts/permutator/generalizeSlot.ts - About 1 hr to fix

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

                      export function DeselectSubject(
                        subjectToBeDeselected: Subject,
                        allSubjects: Subject[],
                        state: IMasterState
                      ): IMasterState {
                      Severity: Minor
                      Found in src/ts/redux/actions/toggleSubjectSelection.ts - About 1 hr to fix

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

                          protected GenerateNewState(state: IMasterState): IMasterState {
                            const targetSubject = find(state.SubjectListState.Subjects, {
                              Code: this.subjectCode,
                            }) as Subject;
                            let selectedSlotsCount = 0;
                        Severity: Minor
                        Found in src/ts/redux/actions/toggleSelectionOnGroupOfSlots.ts - About 1 hr to fix

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

                          export function findSisterSlots(
                            slotsOfCurrentTimetable: IRawSlot[],
                            allSlots: IRawSlot[]
                          ): IRawSlot[] {
                            const currentSlotsAsBigSlots = slotsOfCurrentTimetable.map((x) =>
                          Severity: Minor
                          Found in src/ts/redux/actions/saveTimetable/saveTimetableAsTextFile.ts - About 1 hr to fix

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

                            function moveElement(layout, l, x, y, isUserAction, preventCollision, compactType, cols) {
                              if (l.static) return layout;
                            
                              // Short-circuit if nothing to do.
                              if (l.y === y && l.x === x) return layout;
                            Severity: Minor
                            Found in src/ts/modified_node_modules/react-grid-layout/build/utils.js - About 1 hr to fix

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

                                protected GenerateNewState(state: IMasterState): IMasterState {
                                  const [filtrate, residue] = Filter(
                                    state.TimetableListState.FiltrateTimetables,
                                    this.clickedState
                                  );
                              Severity: Minor
                              Found in src/ts/redux/actions/filterTimetable.ts - About 1 hr to fix

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

                                const Legend = (props: ILegendProps) => {
                                  const background = () => {
                                    switch (props.type) {
                                      case "red":
                                        return ColorOfDefinitelyOccupied;
                                Severity: Minor
                                Found in src/ts/react/setTimeConstraintView.tsx - About 1 hr to fix

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

                                  export const LoadSlotsFromUrl = (
                                    downloadUrl: string,
                                    fileType: string,
                                    started: () => void,
                                    successed: (loadedSlots: IRawSlot[]) => void,
                                  Severity: Minor
                                  Found in src/ts/react/selectCourseView.tsx - About 1 hr to fix
                                    Severity
                                    Category
                                    Status
                                    Source
                                    Language