Coursemology/coursemology2

View on GitHub

Showing 1,214 of 1,261 total issues

Function StudentPerformanceTable has a Cognitive Complexity of 40 (exceeds 5 allowed). Consider refactoring.
Open

const StudentPerformanceTable: FC<Props> = (props) => {
  const {
    students,
    hasPersonalizedTimeline,
    isCourseGamified,

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 reducer has 152 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const reducer = produce((draft: CommentState, action: CommentActionType) => {
  switch (action.type) {
    case SAVE_COMMENT_TAB: {
      draft.permissions = { ...action.permissions };
      draft.settings = { ...action.settings };
Severity: Major
Found in client/app/bundles/course/discussion/topics/store.ts - About 6 hrs to fix

Function SurveysTable has 151 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SurveysTable = (props) => {
  const {
    surveys,
    courseId,
    surveysFlags: { canCreate, studentsCount },
Severity: Major
Found in client/app/bundles/course/survey/pages/SurveyIndex/SurveysTable.jsx - About 6 hrs to fix

Function Option has 151 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Option = forwardRef<OptionRef, OptionProps>((props, ref): JSX.Element => {
  const { disabled, adapter: texts, for: originalOption } = props;

  const [option, setOption] = useState(originalOption);
  const [toBeDeleted, setToBeDeleted] = useState(false);

Function SkillsIndex has 149 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SkillsIndex: FC<Props> = (props) => {
  const { intl } = props;
  const dispatch = useAppDispatch();
  const [isLoading, setIsLoading] = useState(true);
  const [dialogType, setDialogType] = useState(DialogTypes.NewSkill);

Function GenerateTabs has 149 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const GenerateTabs: FC<Props> = (props) => {
  const {
    onExport,
    createConversation,
    deleteConversation,

Function AssessmentsTable has 147 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AssessmentsTable = (props: AssessmentsTableProps): JSX.Element => {
  const { display, assessments } = props.assessments;
  const { t } = useTranslation();

  const columns: ColumnTemplate<AssessmentListData>[] = [

Function AnnouncementForm has 143 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AnnouncementForm: FC<Props> = (props) => {
  const { open, editing, title, onClose, initialValues, onSubmit, canSticky } =
    props;
  const { t } = useTranslation();
  const [whenToPublish, setWhenToPublish] = useState<PublishTime>('now');

Function HeartbeatsTimelineChart has 142 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const HeartbeatsTimelineChart = (
  props: HeartbeatsTimelineChartProps,
): JSX.Element => {
  const { in: heartbeats } = props;

Function default has 140 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (state = initialState, action) {
  switch (action.type) {
    case actions.FETCH_SUBMISSION_SUCCESS:
      return {
        ...state,

Function EventForm has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const EventForm = (props) => {
  const { onSubmit, initialValues, disabled, eventTypes, eventLocations } =
    props;
  const {
    control,

Function AnnouncementCard has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AnnouncementCard: FC<Props> = (props) => {
  const {
    intl,
    announcement,
    showEditOptions,

Function LevelsManager has 139 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LevelsManager = (): JSX.Element => {
  const { canManage, levels } = useAppSelector(getLevels);
  const { t } = useTranslation();
  const dispatch = useAppDispatch();

Severity: Major
Found in client/app/bundles/course/level/pages/LevelsIndex/LevelsManager.tsx - About 5 hrs to fix

Function default has 137 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export default function (state = initialState, action) {
  switch (action.type) {
    case actions.FETCH_SUBMISSION_SUCCESS: {
      const { expMultiplier } = state;
      const submission = action.payload.submission;

Function FileManager has 136 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const FileManager = (props: FileManagerProps): JSX.Element => {
  const { disabled, intl } = props;

  const [materials, setMaterials] = useState(props.materials ?? []);
  const [uploadingMaterials, setUploadingMaterials] = useState<Material[]>([]);
Severity: Major
Found in client/app/bundles/course/assessment/components/FileManager/index.tsx - About 5 hrs to fix

Function ConditionsManager has 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ConditionsManager = (props: ConditionsManagerProps): JSX.Element => {
  const { t } = useTranslation();
  const [conditions, setConditions] = useState(props.conditionsData.conditions);
  const [conditionToCreate, setConditionToCreate] =
    useState<ConditionAbility>();
Severity: Major
Found in client/app/lib/components/extensions/conditions/ConditionsManager.tsx - About 5 hrs to fix

Function AssessmentConditionForm has 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AssessmentConditionForm = (
  props: AnyConditionProps<AssessmentConditionData> & {
    assessments: AvailableAssessments;
  },
): JSX.Element => {

Function UsersIndex has 133 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const UsersIndex: FC<Props> = (props) => {
  const { intl } = props;
  const [isLoading, setIsLoading] = useState(true);
  const [filter, setFilter] = useState({ active: false, role: '' });
  const users = useAppSelector(getAllUserMiniEntities);

Function PersonalTimesShow has 132 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const PersonalTimesShow: FC<Props> = (props) => {
  const { intl } = props;
  const [isLoading, setIsLoading] = useState(true);
  const [isRecomputing, setIsRecomputing] = useState(false);
  const { userId } = useParams();
Severity: Major
Found in client/app/bundles/course/users/pages/PersonalTimesShow/index.tsx - About 5 hrs to fix

Function OptionsManager has 132 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  (props, ref): JSX.Element => {
    const { disabled, for: originalOptions } = props;
    const [options, setOptions] = useState(originalOptions);

    const optionRefs = useRef<Record<OptionEntity['id'], OptionRef>>({});
Severity
Category
Status
Source
Language