Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function UsersIndex has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const UsersIndex: FC<Props> = (props) => {
  const { intl } = props;
  const [isLoading, setIsLoading] = useState(false);
  const [filter, setFilter] = useState({ active: false, role: '' });
  const users = useAppSelector(getAllUserMiniEntities);

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 InstanceUserRoleRequestsTable has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
Open

const InstanceUserRoleRequestsTable: FC<Props> = (props) => {
  const {
    title,
    roleRequests,
    pendingRoleRequests = false,

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 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  render() {
    const { label, errorText, name, disabled, style } = this.props;

    const value = this.props.value ? moment(this.props.value) : null;

Severity: Minor
Found in client/app/lib/components/core/fields/DateTimePicker.jsx - About 1 hr to fix

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

export default function (state = initialState, action) {
  switch (action.type) {
    case actions.FETCH_SUBMISSION_SUCCESS:
    case actions.FINALISE_SUCCESS: {
      return produce(state, (draft) => {

Function formatQuestionFormData has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export const formatQuestionFormData = (data) => {
  const payload = new FormData();
  const filledOptions = data.options.filter(
    (option) => option && (option.option || option.file || option.image_url),
  );
Severity: Minor
Found in client/app/bundles/course/survey/utils/index.js - About 1 hr to fix

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

export default function (state = initialState, action) {
  const { type } = action;
  switch (type) {
    case actionTypes.CREATE_RESPONSE_REQUEST:
    case actionTypes.LOAD_RESPONSE_EDIT_REQUEST:
Severity: Minor
Found in client/app/bundles/course/survey/reducers/responseForm.js - About 1 hr to fix

Function renderLessonPlanItemAssessmentSettingsTable has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderLessonPlanItemAssessmentSettingsTable() {
    const { lessonPlanItemSettings } = this.props;
    const assessmentItemSettings = lessonPlanItemSettings.filter(
      (setting) => setting.component === 'course_assessments_component',
    );
Severity: Minor
Found in client/app/bundles/course/admin/pages/LessonPlanSettings/index.jsx - About 1 hr to fix

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

  render() {
    const { question, dragging, expanded } = this.props;

    return (
      <Accordion expanded={expanded}>

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

  render() {
    const { groups } = this.props;

    if (groups.length < 2) {
      return null;

Function renderRow has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  renderRow(setting) {
    const componentTitle =
      setting.component_title ??
      (subscriptionComponents[setting.component] ? (
        <FormattedMessage {...subscriptionComponents[setting.component]} />

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

  render() {
    const {
      commentForms,
      posts,
      topic,

Function IndividualInvitations has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const IndividualInvitations: FC<Props> = (props) => {
  const { isLoading, permissions, fieldsConfig, intl } = props;
  const { append, fields } = fieldsConfig;

  const appendNewRow = (): void => {

Function Toolbar has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const Toolbar = (props: ToolbarProps): JSX.Element => {
  const { intl } = props;

  const handleDeleteFiles = (e): void => {
    e.preventDefault();

Function SidebarContainer has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  (props, ref): JSX.Element => {
    const smallScreen = useMedia.MinWidth('md');
    const mobile = useMedia.PointerCoarse();

    const [pinned, setPinned] = useState<boolean>();
Severity: Minor
Found in client/app/bundles/course/container/Sidebar/SidebarContainer.tsx - About 1 hr to fix

Function CourseInvitationCodeForm has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CourseInvitationCodeForm: FC<Props> = (props) => {
  const { intl } = props;

  const [code, setCode] = useState('');

Function AllAttemptsIndex has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AllAttemptsIndex: FC<Props> = (props) => {
  const { curAnswerId, index } = props;
  const { t } = useTranslation();
  const { courseId, assessmentId } = useParams();

Function ProgressPanel has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const ProgressPanel = (props): JSX.Element => {
  const { submission } = props;
  const { late, submitter, workflowState } = submission;

  const { t } = useTranslation();

Function NewProgrammingQuestionPage has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NewProgrammingQuestionPage = (): JSX.Element => {
  const [id, setId] = useState<number>();
  const [persisted, setPersisted] = useState(false);

  const createOrUpdate = (

Function renderActions has 43 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderActions = (email: EmailData): JSX.Element | null => {
    if (email.isPrimary) return null;

    const confirmationUrl = email.confirmationEmailPath;
    const setPrimaryUrl = email.setPrimaryUserEmailPath;
Severity: Minor
Found in client/app/bundles/user/components/EmailsList.tsx - About 1 hr to fix

Function MultipleResponseOptionsField has 42 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const MultipleResponseOptionsField = (props) => {
  const {
    disabled,
    field: { onChange, value },
    fieldState: { error },
Severity
Category
Status
Source
Language