Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

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

export const buildQuestionDataFromPrototype = (
  prefilledData: QuestionPrototypeFormData,
  languageId: LanguageData['id'],
  languageMode: LanguageMode,
): ProgrammingFormRequestData => {

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

const ContactableErrorAlert = (
  props: ContactableErrorAlertProps,
): JSX.Element => {
  const {
    children: message,
Severity: Minor
Found in client/app/lib/components/core/layouts/ContactableErrorAlert.tsx - About 1 hr to fix

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

const buildFormData = (draft: ProgrammingFormRequestData): FormData => {
  const data = new FormData();

  appendInto(data, 'title', draft.question.title);
  appendInto(data, 'description', draft.question.description);

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

const Accordion = (props: AccordionProps): JSX.Element => {
  const { title, children, subtitle, disabled, icon, ...accordionProps } =
    props;

  return (
Severity: Minor
Found in client/app/lib/components/core/layouts/Accordion.tsx - About 1 hr to fix

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

  const handleLock = (): Promise<void> => {
    setIsLocking(true);
    return dispatch(
      updateForumTopicLocked(topic.id, topic.topicUrl, topic.isLocked),
    )
Severity: Minor
Found in client/app/bundles/course/forum/components/buttons/LockButton.tsx - About 1 hr to fix

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

const ForumNew: FC<Props> = (props) => {
  const { t } = useTranslation();
  const { open, onClose } = props;
  const dispatch = useAppDispatch();

Severity: Minor
Found in client/app/bundles/course/forum/pages/ForumNew/index.tsx - About 1 hr to fix

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

  const handleHide = (): Promise<void> => {
    setIsHiding(true);
    return dispatch(
      updateForumTopicHidden(topic.id, topic.topicUrl, topic.isHidden),
    )
Severity: Minor
Found in client/app/bundles/course/forum/components/buttons/HideButton.tsx - About 1 hr to fix

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

  const onSubmit = (formData: IFormInputs): Promise<void> => {
    const data = {
      ...formData,
      id: item.id,
    };

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

const CourseInfoBox = (props: CourseInfoBoxProps): JSX.Element => {
  const { course } = props;

  return (
    <Grid item lg={1} md={1} sm={1} style={{ padding: 10 }} xl={1} xs={1}>
Severity: Minor
Found in client/app/bundles/course/courses/components/misc/CourseInfoBox.tsx - About 1 hr to fix

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

const ContinueButton: FC<Props> = (props) => {
  const { stepIndex, onContinue } = props;

  const { t } = useTranslation();
  const assessment = useAppSelector(getAssessment);

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

const StatisticsCharts: FC<Props> = (props) => {
  const { t } = useTranslation();
  const { submissions } = props;

  const noPhantomSubmissions = submissions.filter(

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

  const pollQuestionExportJobs = (): void => {
    Object.values(generatePageData.conversations)
      .filter(
        (conversation) =>
          conversation.exportStatus === 'importing' &&

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

const InstanceAdminNavigator = (): JSX.Element => {
  const { t } = useTranslation();

  return (
    <AdminNavigablePage

Function default has a Cognitive Complexity of 11 (exceeds 5 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;

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

export function processSubmissionsIntoChartData(
  assessments,
  submissions,
  showPhantoms,
) {

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 a Cognitive Complexity of 11 (exceeds 5 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:

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

const GroupUserManager = ({
  dispatch,
  categoryId,
  group,
  groups,

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

const ResponseForm = (props) => {
  const {
    initialValues,
    onSubmit,
    readOnly,
Severity: Minor
Found in client/app/bundles/course/survey/containers/ResponseForm/index.jsx - 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

Method define_permissions has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def define_permissions
    if course_user
      allow_staff_read_groups if course_user.staff?
      allow_teaching_staff_manage_groups if course_user.teaching_staff?
      allow_group_manager_manage_group unless course_user.teaching_staff?
Severity: Minor
Found in app/models/components/course/groups_ability_component.rb - 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

Method process_package has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
Open

  def process_package
    if attachment_changed?
      attachment ? process_new_package : remove_old_package
    elsif should_evaluate_package
      # For non-autograded questions, the attachment is not present
Severity: Minor
Found in app/models/course/assessment/question/programming.rb - 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