Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function GenerateProgrammingQuestionPage has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

const GenerateProgrammingQuestionPage = (): JSX.Element => {
  const params = useParams();
  const id = parseInt(params?.assessmentId ?? '', 10) || undefined;
  if (!id)
    throw new Error(

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

const WarningDialog: FC = () => {
  const { t } = useTranslation();

  const assessment = useAppSelector(getAssessment);
  const submission = useAppSelector(getSubmission);

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

export default function (state = initialState, action) {
  const { type } = action;

  switch (type) {
    case actionTypes.LOAD_SURVEY_REQUEST: {
Severity: Major
Found in client/app/bundles/course/survey/reducers/surveysFlags.js - About 2 hrs to fix

Function render has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const {
      intl,
      conditionAttributes,
      disabled,

Function GlobalAnnouncements has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const GlobalAnnouncements = (
  props: GlobalAnnouncementsProps,
): JSX.Element | null => {
  const [announcements, setAnnouncements] = useState(props.in);

Severity: Major
Found in client/app/lib/containers/AppContainer/GlobalAnnouncements.tsx - About 2 hrs to fix

Function CommentField has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CommentField: FC<Props> = (props: Props) => {
  const { intl, topic, updateStatus } = props;
  const dispatch = useAppDispatch();
  const [value, setValue] = useState('');
  const [disableCommentButton, setDisableCommentButton] = useState(true);

Function CommentsSettingsForm has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CommentsSettingsForm = (
  props: CommentsSettingsFormProps,
): JSX.Element => {
  const { t } = useTranslation();

Function Breadcrumbs has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Breadcrumbs = (props: BreadcrumbProps): JSX.Element => {
  const { in: crumbs } = props;

  const { t } = useTranslation();

Severity: Major
Found in client/app/bundles/course/container/Breadcrumbs/Breadcrumbs.tsx - About 2 hrs to fix

Function TimeLimitBanner has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TimeLimitBanner: FC<Props> = (props) => {
  const { submissionTimeLimitAt } = props;
  const initialCurrentTime = new Date().getTime();
  const initialRemainingTime = submissionTimeLimitAt - initialCurrentTime;

Function InstanceUserRoleRequestsIndex has 52 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InstanceUserRoleRequestsIndex: FC<Props> = (props) => {
  const { intl } = props;
  const [isLoading, setIsLoading] = useState(true);
  const roleRequests = useAppSelector(getAllRoleRequestsMiniEntities);
  const dispatch = useAppDispatch();

Function saveAnswer has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function saveAnswer(answerData, answerId, currentTime, resetField) {
  const answer = formatAnswer(answerData, currentTime);
  const payload = { answer };

  return (dispatch, getState) => {

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

export default function (state = {}, action) {
  switch (action.type) {
    case actions.FETCH_SUBMISSION_SUCCESS:
    case actions.FINALISE_SUCCESS:
    case actions.UNSUBMIT_SUCCESS:
Severity: Major
Found in client/app/bundles/course/assessment/submission/reducers/questions.js - About 2 hrs to fix

Function render has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { section, index: sectionIndex } = this.props;
    return (
      <Card>
        <CardHeader
Severity: Major
Found in client/app/bundles/course/survey/pages/SurveyShow/Section/index.jsx - About 2 hrs to fix

Function ResponseSection has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ResponseSection = (props) => {
  const { control, disabled, section, sectionIndex } = props;
  const { fields: questionFields } = useFieldArray({
    control,
    name: `sections.${sectionIndex}.questions`,

Function renderComments has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderComments(lineNumber, annotation) {
    const {
      activeComment,
      answerId,
      fileId,

Function renderTestCaseRow has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderTestCaseRow(testCase) {
    const {
      testCases: { canReadTests },
    } = this.props;
    const { showPublicTestCasesOutput } = this.props;

Function useMonitoring has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const useMonitoring = (): UseMonitoringHook => {
  const { t } = useTranslation();
  const dispatch = useAppDispatch();

  return {

Function reducer has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const reducer = produce((state, action) => {
  const { type } = action;

  switch (type) {
    case actionTypes.FETCH_SKILLS_REQUEST:
Severity: Major
Found in client/app/bundles/course/assessment/question/scribing/store.ts - About 2 hrs to fix

Function DeleteButton has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DeleteButton = (props: DeleteButtonProps): JSX.Element => {
  const {
    disabled,
    onClick,
    confirmMessage,
Severity: Major
Found in client/app/lib/components/core/buttons/DeleteButton.tsx - About 2 hrs to fix

Function ManageStudents has 51 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ManageStudents: FC<Props> = (props) => {
  const { intl } = props;
  const [isLoading, setIsLoading] = useState(true);

  const students = useAppSelector(getAllStudentMiniEntities);
Severity: Major
Found in client/app/bundles/course/users/pages/ManageStudents/index.tsx - About 2 hrs to fix
Severity
Category
Status
Source
Language