WikiEducationFoundation/WikiEduDashboard

View on GitHub

Showing 462 of 1,667 total issues

Function getList has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const getList = (assignments, currentUserId, ROLE) => {
  return assignments.reduce((acc, { article_title, role, user_id, username }) => {
    if (!user_id || role === ROLE || user_id === currentUserId) return acc;
    if (acc[article_title]) {
      acc[article_title].push(username);

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

const parseCanCreateResponse = (response) => {
  const user = response.query.users[0];
  if (user.cancreateerror) {
    const error = user.cancreateerror[0];
    if (error.code === '_1') {
Severity: Minor
Found in app/assets/javascripts/actions/new_account_actions.js - About 25 mins 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 getFiltered has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const getFiltered = (models, options) => {
  const filteredModels = [];
  for (let i = 0; i < models.length; i += 1) {
    const model = models[i];
    let add = true;
Severity: Minor
Found in app/assets/javascripts/utils/model_utils.js - About 25 mins 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 createAdminCourseNote has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const createAdminCourseNote = (courseId, adminCourseNoteDetails) => async (dispatch) => {
  if ((adminCourseNoteDetails.title.trim().length === 0) || (adminCourseNoteDetails.text.trim().length === 0)) {
    return sendNotification(dispatch, 'Error', 'notes.empty_fields');
  }

Severity: Minor
Found in app/assets/javascripts/actions/admin_course_notes_action.js - About 25 mins 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 default has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export default function (opts) {
  const mergedOpts = assign({}, opts, { html: true, linkify: true });
  const md = markdownIt(mergedOpts).use(footnotes);

  if (mergedOpts.openLinksExternally) {
Severity: Minor
Found in app/assets/javascripts/utils/markdown_it.js - About 25 mins 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 RandomPeerAssignButton has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const RandomPeerAssignButton = ({
  randomPeerAssignments: assignRandomPeer,
  initiateConfirm: confirmInitiate,
  course,
  current_user,

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

const ActivityTableRow = ({ isOpen, diffUrl, revisionDateTime,
  revisionScore, reportUrl, revision, rowId, articleUrl, title, talkPageLink,
  author }) => {
  const dispatch = useDispatch();

Severity: Minor
Found in app/assets/javascripts/components/activity/activity_table_row.jsx - About 25 mins 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 CourseNavbar has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const CourseNavbar = ({ course, location, currentUser, courseLink }) => {
  // ///////////////
  // Course title //
  // ///////////////
  let courseLinkElement;
Severity: Minor
Found in app/assets/javascripts/components/common/course_navbar.jsx - About 25 mins 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 isDayDisabled has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  isDayDisabled(currentDate) {
    if (this.props.date_props) {
      const minDate = startOfDay(this.props.date_props.minDate);
      if (isValid(minDate) && isAfter(minDate, currentDate)) {
        return true;
Severity: Minor
Found in app/assets/javascripts/components/common/date_picker.jsx - About 25 mins 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 Resources has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const Resources = ({ weeks, current_user, course }) => {
  // setting page title
  useEffect(() => {
    document.title = `${course.title} - ${I18n.t('resources.label')}`;
  }, []);
Severity: Minor
Found in app/assets/javascripts/components/resources/resources.jsx - About 25 mins 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 NotesRow has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const NotesRow = ({ notesList }) => {
  // State variables to keep track of the currently edited note and the note with expanded text
  const [editNoteId, setEditNoteId] = useState(null);
  const [showNoteTextId, setShowNoteTextId] = useState(null);
  const [noteText, setNoteText] = useState('');
Severity: Minor
Found in app/assets/javascripts/components/admin_notes/notes_row.jsx - About 25 mins 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 import_articles_from_title_query has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def import_articles_from_title_query(results)
    articles = []
    results.each_value do |page_data|
      next if page_data['missing']
      next if page_data['invalid']
Severity: Minor
Found in lib/importers/article_importer.rb - About 25 mins 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 StatisticsUpdateModal has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const StatisticsUpdateModal = (props) => {
  const course = props.course;
  const helpMessage = Features.wikiEd ? I18n.t('metrics.wiki_ed_help') : I18n.t('metrics.outreach_help');
  const updatesEndMoment = toDate(course.update_until);
  const futureUpdatesRemaining = isAfter(updatesEndMoment, new Date());
Severity: Minor
Found in app/assets/javascripts/components/overview/statistics_update_modal.jsx - About 25 mins 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 send_email has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def self.send_email(alert)
    return unless Features.email?
    return if alert.user.email.blank?
    email(alert).deliver_now
    alert.update(email_sent_at: Time.zone.now)
Severity: Minor
Found in app/mailers/overdue_training_alert_mailer.rb - About 25 mins 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 training_very_overdue? has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def training_very_overdue?(course)
    return false if course.user_count.zero?
    completion_rate = course.trained_count.to_f / course.user_count
    return false unless completion_rate < EXPECTED_COMPLETION_RATE
    latest_training_assignment_date = dates_of_overdue_trainings(course).last
Severity: Minor
Found in lib/alerts/untrained_students_alert_manager.rb - About 25 mins 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 StatisticsUpdateInfo has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const StatisticsUpdateInfo = ({ course }) => {
  const [showModal, setShowModal] = useState(false);

  const toggleModal = () => {
    setShowModal(!showModal);
Severity: Minor
Found in app/assets/javascripts/components/overview/statistics_update_info.jsx - About 25 mins 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 parse_api_response has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def parse_api_response
    # {"edit"=>
    #   {"result"=>"Success",
    #    "pageid"=>11543696,
    #    "title"=>"User:Ragesock",
Severity: Minor
Found in lib/wiki_response.rb - About 25 mins 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 Permissions has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

const Permissions = ({ currentUser, returnToParam }) => {
  const [isHovered, setIsHovered] = useState(false);

  let slide;

Severity: Minor
Found in app/assets/javascripts/components/onboarding/permissions.jsx - About 25 mins 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 import_articles_by_title has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

  def import_articles_by_title(titles)
    # Slice size is limited by max URI length.
    # 40 is too much for some languages, such as bn.wipedia.org
    titles.each_slice(30) do |some_article_titles|
      query = { prop: 'info', titles: some_article_titles }
Severity: Minor
Found in lib/importers/article_importer.rb - About 25 mins 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 AllPeerReviewLinks has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

export const AllPeerReviewLinks = ({ assignment, reviewAssignments }) => {
  const title = <span key="title">Reviews: </span>;
  const reviewLinks = assignment.reviewers.map((reviewer) => {
    let linkClass = '';
    let mouseoverText;

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