Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function buildCrumbsData has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const buildCrumbsData = (
  matches: Match[],
  location: Location,
  state: CrumbState,
): CrumbsDataBuilderResult => {
Severity: Minor
Found in client/app/lib/hooks/router/dynamicNest/builder.ts - About 1 hr to fix

Function createTime has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async (dispatch) => {
    const adaptedData: TimePostData = {
      reference_time: {
        lesson_plan_item_id: itemId,
        start_at: time.startAt,
Severity: Minor
Found in client/app/bundles/course/reference-timelines/operations.ts - About 1 hr to fix

Function updateTime has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  async (dispatch) => {
    const adaptedData: TimePostData = {
      reference_time: {
        start_at: time.startAt,
        bonus_end_at: time.bonusEndAt,
Severity: Minor
Found in client/app/bundles/course/reference-timelines/operations.ts - About 1 hr to fix

Function MaterialsSettings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MaterialsSettings = (): JSX.Element => {
  const reloadItems = useItemsReloader();
  const { t } = useTranslation();
  const [form, setForm] = useState<FormEmitter<MaterialsSettingsData>>();
  const [submitting, setSubmitting] = useState(false);
Severity: Minor
Found in client/app/bundles/course/admin/pages/MaterialsSettings/index.tsx - About 1 hr to fix

Function AnnouncementsSettings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AnnouncementsSettings = (): JSX.Element => {
  const reloadItems = useItemsReloader();
  const { t } = useTranslation();
  const [form, setForm] = useState<FormEmitter<AnnouncementsSettingsData>>();
  const [submitting, setSubmitting] = useState(false);

Function CommentsSettings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CommentsSettings = (): JSX.Element => {
  const reloadItems = useItemsReloader();
  const { t } = useTranslation();
  const [form, setForm] = useState<FormEmitter<CommentsSettingsData>>();
  const [submitting, setSubmitting] = useState(false);
Severity: Minor
Found in client/app/bundles/course/admin/pages/CommentsSettings/index.tsx - About 1 hr to fix

Function ForumsSettings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ForumsSettings = (): JSX.Element => {
  const reloadItems = useItemsReloader();
  const { t } = useTranslation();
  const [form, setForm] = useState<FormEmitter<ForumsSettingsData>>();
  const [submitting, setSubmitting] = useState(false);
Severity: Minor
Found in client/app/bundles/course/admin/pages/ForumsSettings/index.tsx - About 1 hr to fix

Function LeaderboardSettings has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LeaderboardSettings = (): JSX.Element => {
  const reloadItems = useItemsReloader();
  const { t } = useTranslation();
  const [form, setForm] = useState<FormEmitter<LeaderboardSettingsData>>();
  const [submitting, setSubmitting] = useState(false);
Severity: Minor
Found in client/app/bundles/course/admin/pages/LeaderboardSettings/index.tsx - About 1 hr to fix

Function UploadButton has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

    const handleFileInputChange: ChangeEventHandler<HTMLInputElement> = (e) => {
      if (props.disabled) return;

Function CourseItem has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CourseItem = (props: CourseItemProps): JSX.Element => {
  const { in: data } = props;

  const menuRef = useRef<ComponentRef<typeof CourseSwitcherPopupMenu>>(null);

Severity: Minor
Found in client/app/bundles/course/container/Sidebar/CourseItem.tsx - About 1 hr to fix

Function CoursesNew has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const dispatch = useAppDispatch();
Severity: Minor
Found in client/app/bundles/course/courses/pages/CoursesNew/index.tsx - About 1 hr to fix

Function FolderNew has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const FolderNew: FC<Props> = (props) => {
  const { folderId, isOpen, onClose } = props;
  const { t } = useTranslation();
  const dispatch = useAppDispatch();

Function FolderEdit has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const FolderEdit: FC<Props> = (props) => {
  const { isOpen, onClose, folderId, initialValues } = props;
  const { t } = useTranslation();

  const dispatch = useAppDispatch();

Function NewQuestionMenu has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NewQuestionMenu = (props: NewQuestionMenuProps): JSX.Element => {
  const { with: newQuestionUrls } = props;
  const { t } = useTranslation();
  const [creating, setCreating] = useState(false);
  const newQuestionButton = useRef<HTMLButtonElement>(null);

Function SaveDraftButton has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SaveDraftButton: FC = () => {
  const { t } = useTranslation();
  const dispatch = useAppDispatch();

  const {

Function TestCases has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TestCases: FC<Props> = (props) => {
  const { testCase } = props;

  return (
    <div className="my-5 space-y-5">

Function renderStatusBadge has 28 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderStatusBadge = (email: EmailData): JSX.Element => {
    if (email.isPrimary)
      return (
        <Chip
          className="select-none"
Severity: Minor
Found in client/app/bundles/user/components/EmailsList.tsx - About 1 hr to fix

Function groupItemsUnderMilestones has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

export function groupItemsUnderMilestones(items, milestones) {
  const sortedMilestones = [...milestones].sort(sortByStartAt);
  const sortedItems = [...items].sort((a, b) => {
    const startAtSortResult = sortByStartAt(a, b);
    if (startAtSortResult !== 0) {
Severity: Minor
Found in client/app/bundles/course/lesson-plan/reducers/utils.js - 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

Function formatAnswerSpecific has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const formatAnswerSpecific = (answer) => {
  const answerMap = {
    [questionTypes.MultipleChoice]: () => ({
      option_ids: answer.option_ids,
    }),
Severity: Minor
Found in client/app/bundles/course/assessment/submission/actions/utils.js - 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

Function getCreateGroupMessage has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
Open

const getCreateGroupMessage = (intl) => (created, failed) => {
  if (created.length === 0) {
    if (failed.length === 1) {
      return intl.formatMessage(translations.createSingleFailure, {
        groupName: failed[0].name,

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