Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function VideoShow has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const VideoShow: FC<Props> = (props) => {
  const { intl } = props;
  const { videoId } = useParams();
  const [isLoading, setIsLoading] = useState(true);
  const dispatch = useAppDispatch();
Severity: Major
Found in client/app/bundles/course/video/pages/VideoShow/index.tsx - About 2 hrs to fix

Function VideoSubmissionShow has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const VideoSubmissionShow: FC<Props> = (props) => {
  const { intl } = props;
  const { submissionId } = useParams();
  const [isLoading, setIsLoading] = useState(true);
  const [videoSubmission, setVideoSubmission] = useState<VideoSubmissionData>();

Function ReevaluateButton has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ReevaluateButton: FC<Props> = (props) => {
  const { t } = useTranslation();
  const { questionId } = props;

  const assessment = useAppSelector(getAssessment);

Function PackageDetails has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const PackageDetails = (props: PackageDetailsProps): JSX.Element | null => {
  const { t } = useTranslation();

  const { question, packageUi } = useProgrammingFormDataContext();
  if (!question.package) return null;

Function LandingPage has 56 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LandingPage = (): JSX.Element => {
  const { t } = useTranslation();
  const auth = useAuthAdapter();

  return (
Severity: Major
Found in client/app/bundles/common/LandingPage.tsx - About 2 hrs to fix

Function MuiFilterMenu has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MuiFilterMenu = (props: FilterProps): JSX.Element => {
  const { filters } = props;

  const { t } = useTranslation();

Severity: Major
Found in client/app/lib/components/table/MuiTableAdapter/MuiFilterMenu.tsx - About 2 hrs to fix

Function InstanceForm has 55 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InstanceForm: FC<Props> = (props) => {
  const { open, onClose, onSubmit } = props;
  const { t } = useTranslation();

  return (

Class TestCase has 21 methods (exceeds 20 allowed). Consider refactoring.
Open

  class TestCase
    attr_reader :test_suite

    # Creates a new test case. This represents a \<testcase> element.
    #
Severity: Minor
Found in lib/autoload/course/assessment/programming_test_case_report.rb - About 2 hrs to fix

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

export default function (state = initialState, action) {
  switch (action.type) {
    case actions.SAVE_GRADE_SUCCESS: {
      const initialValues = convertAnswersDataToInitialValues(
        action.payload.answers,
Severity: Major
Found in client/app/bundles/course/assessment/submission/reducers/answers.js - About 2 hrs to fix

Function CourseUserProgress has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CourseUserProgress = (props: CourseUserProgressProps): JSX.Element => {
  const { from: data } = props;

  const { t } = useTranslation();

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

Function NewCourseForm has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NewCourseForm: FC<Props> = (props) => {
  const { open, title, onClose, initialValues, onSubmit } = props;
  const { t } = useTranslation();

  return (
Severity: Major
Found in client/app/bundles/course/courses/components/forms/NewCourseForm.tsx - About 2 hrs to fix

Function PersonalTimesTable has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const PersonalTimesTable: FC<Props> = (props) => {
  const { personalTimes, intl } = props;

  const renderRow = (item: PersonalTimeMiniEntity): JSX.Element => {
    return (

Function UserManagementButtons has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const UserManagementButtons: FC<Props> = (props) => {
  const { intl, user } = props;
  const dispatch = useAppDispatch();
  const [isDeleting, setIsDeleting] = useState(false);
  const { t } = useTranslation();

Function AssessmentsIndex has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AssessmentsIndex = (): JSX.Element => {
  const [params, setParams] = useSearchParams();
  const categoryId = parseInt(params.get('category') ?? '', 10) || undefined;
  const tabId = parseInt(params.get('tab') ?? '', 10) || undefined;

Severity: Major
Found in client/app/bundles/course/assessment/pages/AssessmentsIndex/index.tsx - About 2 hrs to fix

Function PostPack has 54 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const PostPack: FC<Props> = (props) => {
  const { postPack } = props;
  const courseId = getCourseId();
  const [isExpanded, setIsExpanded] = useState(false);

Function QuestionFormOptions has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const QuestionFormOptions = (props) => {
  const {
    fieldsConfig,
    disabled,
    multipleChoice,

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

  render() {
    const {
      creator: { name, imageUrl },
      createdAt,
      canUpdate,

Function customBodyRenderLite has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

        customBodyRenderLite: (dataIndex): JSX.Element | null => {
          const topic = forumTopics[dataIndex];
          const firstPostCreator = topic.firstPostCreator;
          const postCreatorObject =
            firstPostCreator &&
Severity: Major
Found in client/app/bundles/course/forum/components/tables/ForumTopicTable.tsx - About 2 hrs to fix

Method update_todo has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  def update_todo
    return unless todo

    if attempting?
      todo.update_attribute(:workflow_state, 'in_progress') unless todo.in_progress?
Severity: Minor
Found in app/models/concerns/course/assessment/submission/todo_concern.rb - About 2 hrs 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 renderTestCases has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

  renderTestCases(testCases, testCaseType, warn, isDraftAnswer) {
    const {
      collapsible,
      testCases: { canReadTests },
      graderView,

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