Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function Form has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
Open

const Form = <
  D extends Data = any,
  M extends boolean = false,
  V extends AnyObjectSchema = never,
>(
Severity: Minor
Found in client/app/lib/components/form/Form.tsx - About 3 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 render has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { fieldVisible } = this.state;
    const {
      fileId,
      lineNumber,

Function IndividualInviteForm has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const IndividualInviteForm: FC<Props> = (props) => {
  const { openResultDialog, intl } = props;
  const [isLoading, setIsLoading] = useState(false);
  const dispatch = useAppDispatch();
  const sharedData = useAppSelector(getManageCourseUsersSharedData);

Function TimeBar has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TimeBar = (props: TimeBarProps): JSX.Element => {
  const [{ start, bonus, end }, setTime] = useState<TimeTriplet>(
    generateTriplet(props.startsAt, props.bonusEndsAt, props.endsAt),
  );

Function PackageFields has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const PackageFields = (props: PackageFieldsProps): JSX.Element => {
  const { t } = useTranslation();

  const { control, watch } = useFormContext<ProgrammingFormData>();

Function AssessmentAuthenticate has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AssessmentAuthenticate = (
  props: AssessmentAuthenticateProps,
): JSX.Element => {
  const { for: assessment } = props;
  const [submitting, setSubmitting] = useState(false);

Function ForgotPasswordPage has 81 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const [email, setEmail] = useEmailFromAuthPagesContext();

Severity: Major
Found in client/app/bundles/users/pages/ForgotPasswordPage.tsx - About 3 hrs to fix

Function ForumTopicShow has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ForumTopicShow: FC = () => {
  const { t } = useTranslation();
  const { forumId, topicId } = useParams();
  // Need to get the topic Id number below as sometimes, the topicId in the URL is in the form of slug.
  // The topic id number is required to to select the entity from the redux store.
Severity: Major
Found in client/app/bundles/course/forum/pages/ForumTopicShow/index.tsx - About 3 hrs to fix

Function LeaderboardSettingsForm has 80 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Class SubmissionsController has 27 methods (exceeds 20 allowed). Consider refactoring.
Open

class Course::Assessment::Submission::SubmissionsController < # rubocop:disable Metrics/ClassLength
  Course::Assessment::Submission::Controller
  include Course::Assessment::Submission::SubmissionsControllerServiceConcern
  include Signals::EmissionConcern
  include Course::Assessment::Submission::MonitoringConcern

Function renderCommentContent has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderCommentContent = (): JSX.Element => {
    if (editMode) {
      return (
        <>
          {renderRating()}

Function ExperiencePointsDetails has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ExperiencePointsDetails = (): JSX.Element => {
  const [pageNum, setPageNum] = useState(1);
  const [isLoading, setIsLoading] = useState(true);
  const [isDownloading, setIsDownloading] = useState(false);

Function PointManagementButtons has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const PointManagementButtons: FC<Props> = (props) => {
  const {
    permissions,
    data,
    isManuallyAwarded,

Function InvitationResultUsersTable has 79 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InvitationResultUsersTable: FC<Props> = (props) => {
  const { title, users, intl } = props;

  const options: TableOptions = {
    download: true,

Function UserRequests has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const UserRequests: FC<Props> = (props) => {
  const { intl } = props;
  const [isLoading, setIsLoading] = useState(true);
  const enrolRequests = useAppSelector(getAllEnrolRequestEntities);
  const permissions = useAppSelector(getManageCourseUserPermissions);
Severity: Major
Found in client/app/bundles/course/enrol-requests/pages/UserRequests/index.tsx - About 3 hrs to fix

Function PostCreatorObject has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const PostCreatorObject = (props: PostCreatorProps): PostCreatorReturnProps => {
  const { creator, canViewAnonymous = false, isAnonymous = false } = props;
  const { t } = useTranslation();
  const [hideAvatar, setHideAvatar] = useState(true);

Severity: Major
Found in client/app/bundles/course/forum/components/misc/PostCreatorObject.tsx - About 3 hrs to fix

Function StaffStatisticsTable has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const StaffStatisticsTable: FC<Props> = (props) => {
  const { staffs } = props;
  const { t } = useTranslation();
  const formattedStaffs = staffs.map(processStaff);

Function IndividualInviteForm has 78 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const IndividualInviteForm: FC<Props> = (props) => {
  const { openResultDialog, intl } = props;
  const [isLoading, setIsLoading] = useState(false);
  const dispatch = useAppDispatch();
  const emptyInvitation = {

Function reducer has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
Open

const reducer = produce((draft: CoursesState, action: CoursesActionType) => {
  switch (action.type) {
    case SAVE_COURSE_LIST: {
      const courseList = action.courseList;
      const entityList = courseList.map((data) => ({
Severity: Minor
Found in client/app/bundles/course/courses/store.ts - About 3 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 VideosTabsManager has 76 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const VideosTabsManager = (props: VideosTabsManagerProps): JSX.Element => {
  const { tabs } = props;
  const { t } = useTranslation();

  const renameTab = (index: number, newTitle: VideosTab['title']): void =>
Severity
Category
Status
Source
Language