Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function renderCategoryCard has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static renderCategoryCard(category, orphanTabs, orphanAssessments) {
    const hasOrphanAssessments =
      orphanAssessments && orphanAssessments.length > 0;
    const hasOrphanTabs = orphanTabs && orphanTabs.length > 0;
    const categoryRow = category

Function renderOptionsToDelete has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderOptionsToDelete = () => {
    const shouldRenderOptionsToDelete =
      deletedOptions && deletedOptions.length > 0;
    if (!shouldRenderOptionsToDelete) {
      return null;

Function renderBody has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderBody = () => {
    const { sections, canUpdate } = survey;
    if (!canUpdate) return null;

    if (!sections || sections.length < 1)
Severity: Minor
Found in client/app/bundles/course/survey/pages/SurveyShow/index.jsx - About 1 hr to fix

Function Topic has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Topic = (props) => {
  if (props.postIds.length === 0) {
    return null;
  }

Function renderOutputStream has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  static renderOutputStream(outputStreamType, output, showStaffOnlyWarning) {
    return (
      <Accordion
        defaultExpanded={false}
        disabled={!output}

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

  render() {
    const { expanded } = this.state;
    const { answerId, annotations, file, isUpdatingAnnotationAllowed } =
      this.props;
    const editorProps = {

Method explanations_for_points_summary_incorrect has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  def explanations_for_points_summary_incorrect(question, answer_text_array,
                                                answer_text_lemma_status, correct_points, hash_point_serial)
    explanations = []

    question.groups.flat_map(&:points).each do |point|

Function RollbarProvider has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const RollbarProvider = (props: RollbarProviderProps): JSX.Element => {
  // TODO: To report user id as well after we move to SPA.
  const rollbarConfig =
    process.env.NODE_ENV === 'development'
      ? {}
Severity: Minor
Found in client/app/lib/components/wrappers/RollbarWrapper.tsx - About 1 hr to fix

Function MuiTablePagination has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MuiTablePagination = (props: PaginationProps): JSX.Element => {
  const { t } = useTranslation();

  const rowsPerPageOptions = useMemo(() => {
    const options: RowsPerPageOptions = props.pages?.slice() ?? [];

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

  (draft: AnnouncementsState, action: AnnouncementsActionType) => {
    switch (action.type) {
      case SAVE_ANNOUNCEMENT_LIST: {
        const announcementList = action.announcementList;
        const entityList = announcementList.map((data) => ({ ...data }));
Severity: Minor
Found in client/app/bundles/course/announcements/store.ts - About 1 hr to fix

Function TopicList has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TopicList: FC<TopicListProps> = (props) => {
  const { listIsLoading, topicList } = props;
  const { t } = useTranslation();

  if (listIsLoading) {

Function renderForm has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderForm = (): JSX.Element | null => {
    if (type === 'subfolder' && folderInitialValues) {
      return (
        <FolderEdit
          folderId={itemId}

Function ConvertMcqMrqButton has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ConvertMcqMrqButton = (props: ConvertMcqMrqButtonProps): JSX.Element => {
  const { for: question } = props;

  const [converting, setConverting] = useState(false);

Function handleTimelineChange has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const handleTimelineChange = (event): void => {
    if (currentUser) {
      const newTimeline = event.target.value;
      const data: CourseUserEntity = {
        ...currentUser,
Severity: Minor
Found in client/app/bundles/course/users/pages/PersonalTimesShow/index.tsx - About 1 hr to fix

Function SubmitEmptyFormButton has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const submission = useAppSelector(getSubmission);
  const submissionFlags = useAppSelector(getSubmissionFlags);

Function AutogradeSubmissionButton has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const dispatch = useAppDispatch();
  const submission = useAppSelector(getSubmission);

Function TestCasesHint has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  return (
    <>

Function duplicate has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const duplicate = async (duplicationUrl: string): Promise<void> => {
    setDuplicating(true);

    const toast = loadingToast(t(translations.duplicatingQuestion));

Function ProgrammingFile has 26 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ProgrammingFile: FC<ProgrammingFileProps> = (props) => {
  const {
    answerId,
    fieldName,
    file,

Function ErrorText has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
Open

const ErrorText = ({ errors }) => {
  if (
    !errors ||
    (errors.constructor === Object && Object.keys(errors).length === 0) ||
    (errors.constructor === Array && errors.length === 0)
Severity: Minor
Found in client/app/lib/components/core/ErrorText.jsx - About 55 mins 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