Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function SidebarItem has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SidebarItem = (props: SidebarItemProps): JSX.Element => {
  const { of: item, square, exact, activePath } = props;

  const location = useLocation();
  const activeUrl = activePath ?? location.pathname + location.search;
Severity: Minor
Found in client/app/bundles/course/container/Sidebar/SidebarItem.tsx - About 1 hr to fix

Function ActivityCenter has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ActivityCenter = (props: ActivityCenterProps): JSX.Element => {
  const { t } = useTranslation();
  const history = useAppSelector(select('history'));
  const monitoring = useMonitoring();

Function TestCaseRow has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TestCaseRow: FC<Props> = (props) => {
  const { result } = props;

  const nameRegex = /\/?(\w+)$/;
  const idMatch = result.identifier?.match(nameRegex);

Function InstancesButtons has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InstancesButtons: FC<Props> = (props) => {
  const { intl, instance } = props;
  const dispatch = useAppDispatch();
  const [isDeleting, setIsDeleting] = useState(false);

Function ForbiddenPage has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const sourceURL = useLoaderData() as string | null;

Severity: Minor
Found in client/app/bundles/common/ErrorPage.tsx - About 1 hr to fix

Function videoSessionReducer has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

function videoSessionReducer(state = initialState, action) {
  if (!state.sessionId) {
    return state;
  }
  const events = state.sessionEvents;
Severity: Minor
Found in client/app/bundles/course/video/submission/reducers/video.js - About 1 hr to fix

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

  render() {
    const { dispatch, columnsVisible } = this.props;

    return (
      <>

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

export default function (state = initialState, action) {
  switch (action.type) {
    case actionTypes.RECORDER_SET_RECORDING: {
      const { recordingComponentId } = action.payload || {};
      return {

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

  render() {
    const {
      dispatch,
      open,
      destinationCourseId,

Function renderLessonPlanItemSettingsForComponentsTable has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderLessonPlanItemSettingsForComponentsTable() {
    const { lessonPlanItemSettings } = this.props;
    const componentItemSettings = lessonPlanItemSettings.filter((setting) =>
      ['course_videos_component', 'course_survey_component'].includes(
        setting.component,
Severity: Minor
Found in client/app/bundles/course/admin/pages/LessonPlanSettings/index.jsx - About 1 hr to fix

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

  renderBody() {
    const {
      isLoading,
      isCourseSelected,
      duplicationMode,
Severity: Minor
Found in client/app/bundles/course/duplication/pages/Duplication/index.jsx - About 1 hr to fix

Function DrawPopover has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DrawPopover = (props) => {
  const {
    intl,
    open,
    anchorEl,

Function AnnouncementEdit has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AnnouncementEdit: FC<Props> = (props) => {
  const {
    open,
    onClose,
    announcementId,

Function MoveAssessmentsMenu has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MoveAssessmentsMenu = (
  props: MoveAssessmentsMenuProps,
): JSX.Element | null => {
  const { t } = useTranslation();
  const { tabs, onSelectTab } = props;

Function UserMenuButton has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const UserMenuButton = (): JSX.Element | null => {
  const { user } = useAppContext();
  const auth = useAuthAdapter();

  const { t } = useTranslation();
Severity: Minor
Found in client/app/lib/components/navigation/BrandingHead.tsx - About 1 hr to fix

Function AchievementReordering has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AchievementReordering = (
  props: AchievementReorderingProps,
): JSX.Element => {
  const { handleReordering, isReordering } = props;

Function TestCasesTable has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TestCasesTable = (
  props: TestCasesTableProps & { children: ReactNode },
): JSX.Element => {
  const { t } = useTranslation();

Function UnavailableMessage has 40 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const UnavailableMessage = (
  props: UnavailableMessageProps,
): JSX.Element | null => {
  const { for: assessment } = props;
  const { t } = useTranslation();

Function render has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  render() {
    const {
      intl,
      open,
      onCancel,
Severity: Minor
Found in client/app/lib/components/core/dialogs/ConfirmationDialog.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 topic_created has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

  def topic_created(user, course_user, topic)
    course = topic.forum.course
    email_enabled = course.email_enabled(:forums, :new_topic)
    return unless email_enabled.regular || email_enabled.phantom

Severity: Minor
Found in app/notifiers/course/forum/topic_notifier.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