Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function InviteUsersRegistrationCode has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const InviteUsersRegistrationCode: FC<Props> = (props) => {
  const { open, handleClose, intl } = props;
  const [isLoading, setIsLoading] = useState(false);

  const registrationCode = useAppSelector(getCourseRegistrationKey);

Function CourseShow has 88 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Class Programming has 29 methods (exceeds 20 allowed). Consider refactoring.
Open

class Course::Assessment::Question::Programming < ApplicationRecord # rubocop:disable Metrics/ClassLength
  enum :package_type, { zip_upload: 0, online_editor: 1 }

  # The table name for this model is singular.
  self.table_name = table_name.singularize
Severity: Minor
Found in app/models/course/assessment/question/programming.rb - About 3 hrs to fix

Function InvitationResultInvitationsTable has 87 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const options: TableOptions = {
    download: true,

Function ResponseForm has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ResponseForm = (props) => {
  const {
    initialValues,
    onSubmit,
    readOnly,
Severity: Major
Found in client/app/bundles/course/survey/containers/ResponseForm/index.jsx - About 3 hrs to fix

Function AssessmentStatisticsPage has 86 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AssessmentStatisticsPage: FC = () => {
  const { t } = useTranslation();
  const [tabValue, setTabValue] = useState('marksPerQuestion');
  const [includePhantom, setIncludePhantom] = useState(false);

Function ResponseIndex has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

const ResponseIndex = (props) => {
  const { dispatch, survey, responses, isLoading } = props;
  const { palette } = useTheme();
  const { NOT_STARTED, RESPONDING, SUBMITTED } = responseStatus;
  const dataColor = {
Severity: Minor
Found in client/app/bundles/course/survey/pages/ResponseIndex/index.jsx - 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 customFooter has 85 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    customFooter: () => {
      return (
        <TableFooter>
          <TableRow>
            <TableCell

Function ForumShow has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

Function DurationBar has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DurationBar = (props: DurationBarProps): JSX.Element => {
  const start = moment(props.starts).startOf('day');
  const bonus = props.bonusEnds && moment(props.bonusEnds).startOf('day');
  const end = props.ends && moment(props.ends).startOf('day');

Function TableMaterialRow has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const TableMaterialRow: FC<Props> = (props) => {
  const { currFolderId, material, isCurrentCourseStudent, isConcrete } = props;

  return (
    <TableRow id={`material-${material.id}`}>

Function QuestionsManager has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const QuestionsManager = (props: QuestionsManagerProps): JSX.Element => {
  const { t } = useTranslation();
  const [questions, setQuestions] = useState(props.of);
  const [submitting, setSubmitting] = useState(false);
  const [currentDestination, setCurrentDestination] = useState<number>();

Function ResendConfirmationEmailPage has 84 lines of code (exceeds 25 allowed). Consider refactoring.
Open

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

  const [email, setEmail] = useEmailFromAuthPagesContext();

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

ScribingToolbar has 28 functions (exceeds 20 allowed). Consider refactoring.
Open

class ScribingToolbar extends Component {
  constructor(props) {
    super(props);
    this.state = {
      colorDropdowns: initializeColorDropdowns(),

Class Course has 28 methods (exceeds 20 allowed). Consider refactoring.
Open

class Course < ApplicationRecord
  include Course::SearchConcern
  include Course::DuplicationConcern
  include Course::CourseComponentsConcern
  include TimeZoneConcern
Severity: Minor
Found in app/models/course.rb - About 3 hrs to fix

Function LiveFeedbackToggleButton has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LiveFeedbackToggleButton: FC<LiveFeedbackToggleButtonProps> = (props) => {
  const { assessmentIds, for: title, hideChipIndicator } = props;
  const { t } = useTranslation();

  const dispatch = useAppDispatch();

Function IndividualInvitation has 83 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const IndividualInvitation: FC<Props> = (props) => {
  const { permissions, fieldsConfig, index, intl } = props;

  const renderInvitationBody = (
    <Grid alignItems="center" container flexWrap="nowrap">

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

export default function (state = {}, action) {
  switch (action.type) {
    case actions.FETCH_SUBMISSION_SUCCESS:
    case actions.UNSUBMIT_SUCCESS:
    case actions.FINALISE_SUCCESS:

Function UserVideoSubmissionsTable has 82 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const UserVideoSubmissionsTable: FC<Props> = (props) => {
  const { videoSubmissions, intl } = props;

  if (!videoSubmissions || videoSubmissions.length === 0) {
    return <Note message="This course has no video yet!" />;

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

  render() {
    const { scribing } = this.props;
    const toolBarStyle = !scribing.isCanvasLoaded
      ? styles.disabledToolbar
      : styles.toolBar;

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