Coursemology/coursemology2

View on GitHub

Showing 1,205 of 1,252 total issues

Function LanguageFields has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LanguageFields = (props: LanguageFieldsProps): JSX.Element => {
  const { t } = useTranslation();

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

Function LogsContent has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LogsContent: FC<Props> = (props) => {
  const { with: data } = props;
  const { t } = useTranslation();

  if (data && data.length === 0) {

Function SkillManagementButtons has 72 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SkillManagementButtons: FC<Props> = (props) => {
  const {
    id,
    canUpdate,
    canDestroy,

Function CourseSettings has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CourseSettings = (): JSX.Element => {
  const reloadItems = useItemsReloader();
  const { t } = useTranslation();
  const [form, setForm] = useState<FormEmitter<CourseInfo>>();
  const [reloadForm, setReloadForm] = useState(false);
Severity: Major
Found in client/app/bundles/course/admin/pages/CourseSettings/index.tsx - About 2 hrs to fix

Function DataFilesManager has 71 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const DataFilesManager = (props: DataFilesManagerProps): JSX.Element => {
  const { t } = useTranslation();

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

Class Assessment has 25 methods (exceeds 20 allowed). Consider refactoring.
Open

class Course::Assessment < ApplicationRecord
  acts_as_lesson_plan_item has_todo: true
  acts_as_conditional
  has_one_folder

Severity: Minor
Found in app/models/course/assessment.rb - About 2 hrs to fix

Function SurveyConditionForm has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const SurveyConditionForm = (
  props: AnyConditionProps<SurveyConditionData> & { surveys: AvailableSurveys },
): JSX.Element => {
  const { ids, surveys } = props.surveys;
  const { t } = useTranslation();

Function renderStatus has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const renderStatus = (): JSX.Element | null => {
    switch (status) {
      case CommentStatusTypes.loading:
        return (
          <div

Function AchievementAward has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AchievementAward: FC<Props> = (props) => {
  const { achievementId, open, handleClose, intl } = props;

  const [discardDialogOpen, setDiscardDialogOpen] = useState(false);
  const [isDirty, setIsDirty] = useState(false);

Function onSubmit has 70 lines of code (exceeds 25 allowed). Consider refactoring.
Open

  const onSubmit = (formData: SkillFormData, setError): Promise<void> => {
    switch (dialogType) {
      case DialogTypes.NewSkill:
        return dispatch(createSkill(formData))
          .then((response) => {

Function formatAnswerSpecific has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const formatAnswerSpecific = (answer) => {
  const answerMap = {
    [questionTypes.MultipleChoice]: () => ({
      option_ids: answer.option_ids,
    }),
Severity: Major
Found in client/app/bundles/course/assessment/submission/actions/utils.js - About 2 hrs to fix

Function importProgrammingFiles has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

export function importProgrammingFiles(answerId, files, language, resetField) {
  const filesPayload = files.map((file) => ({
    id: file.id,
    filename: file.filename,
    content: file.content,

Function AchievementsIndex has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AchievementsIndex: FC = () => {
  const { t } = useTranslation();
  const [isLoading, setIsLoading] = useState(true);
  const [isOpen, setIsOpen] = useState(false);
  const [isReordering, setIsReordering] = useState(false);

Function NotificationCard has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const NotificationCard: FC<Props> = (props) => {
  const { intl, notification } = props;

  let actableLink = '';
  let concatMessage = '';

Function CoursesIndex has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const CoursesIndex: FC = () => {
  const { t } = useTranslation();

  const [params] = useSearchParams();

Severity: Major
Found in client/app/bundles/course/courses/pages/CoursesIndex/index.tsx - About 2 hrs to fix

Function LiveFeedbackDetails has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const LiveFeedbackDetails: FC<Props> = (props) => {
  const { t } = useTranslation();
  const { file } = props;

  const startingLineNum = Math.min(

Function AssessmentSessionNew has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const AssessmentSessionNew = (): JSX.Element => {
  const [submitting, setSubmitting] = useState(false);
  const { t } = useTranslation();
  const navigate = useNavigate();
  const [params] = useSearchParams();

Function WarningDialog has 69 lines of code (exceeds 25 allowed). Consider refactoring.
Open

const WarningDialog: FC = () => {
  const { t } = useTranslation();

  const assessment = useAppSelector(getAssessment);
  const submission = useAppSelector(getSubmission);

Function Dashboard has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

const Dashboard = (props) => {
  const { dispatch, intl, isLoading, nodes, response, selectedElement } = props;

  const [deleteArrowConfirmation, setDeleteArrowConfirmation] = useState(false);
  const isEmptyResponse =
Severity: Minor
Found in client/app/bundles/course/learning-map/containers/Dashboard/index.jsx - About 2 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 renderDownloadDropdown has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
Open

  renderDownloadDropdown() {
    const {
      assessment,
      handleDownload,
      handleDownloadStatistics,

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