Showing 199 of 199 total issues

Avoid too many return statements within this function.
Open

    return {
      ...state,
      [placeholderId]: true,
    };
Severity: Major
Found in vj4/ui/components/messagepad/reducers/isPosting.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

        return {
          ...state,
          records: {
            ...state.records,
            isLoading: false,
    Severity: Major
    Found in vj4/ui/components/scratchpad/reducers/ui.js - About 30 mins to fix

      Avoid too many return statements within this function.
      Open

            return {
              ...state,
              [id]: false,
            };
      Severity: Major
      Found in vj4/ui/components/messagepad/reducers/isPosting.js - About 30 mins to fix

        Avoid too many return statements within this function.
        Open

            return state;
        Severity: Major
        Found in vj4/ui/components/messagepad/reducers/inputs.js - About 30 mins to fix

          Avoid too many return statements within this function.
          Open

              return setting.factory()
          Severity: Major
          Found in vj4/model/adaptor/setting.py - About 30 mins to fix

            Avoid too many return statements within this function.
            Open

                  return {
                    ...state,
                    [id]: {
                      ...state[id],
                      reply: [
            Severity: Major
            Found in vj4/ui/components/messagepad/reducers/dialogues.js - About 30 mins to fix

              Avoid too many return statements within this function.
              Open

                  return {
                    ..._.omit(state, placeholderId),
                    [action.payload.mdoc._id]: false,
                  };
              Severity: Major
              Found in vj4/ui/components/messagepad/reducers/isPosting.js - About 30 mins to fix

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                function renderItem(user) {
                  return tpl`
                    <div class="media">
                      <div class="media__left medium">
                        <img class="small user-profile-avatar" src="${user.gravatar_url}" width="30" height="30">
                Severity: Minor
                Found in vj4/ui/components/autocomplete/UserSelectAutoComplete.js and 1 other location - About 30 mins to fix
                vj4/ui/components/autocomplete/DomainSelectAutoComplete.js on lines 15..27

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 45.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

                Similar blocks of code found in 2 locations. Consider refactoring.
                Open

                function renderItem(domain) {
                  return tpl`
                    <div class="media">
                      <div class="media__left medium">
                        <img class="small domain-profile-avatar" src="${domain.gravatar_url}" width="30" height="30">
                Severity: Minor
                Found in vj4/ui/components/autocomplete/DomainSelectAutoComplete.js and 1 other location - About 30 mins to fix
                vj4/ui/components/autocomplete/UserSelectAutoComplete.js on lines 15..27

                Duplicated Code

                Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

                Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

                When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

                Tuning

                This issue has a mass of 45.

                We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

                The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

                If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

                See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

                Refactorings

                Further Reading

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

                pjax.request = async opt => {
                  const options = {
                    method: 'get',
                    push: true,
                    ...opt,
                Severity: Minor
                Found in vj4/ui/utils/pjax.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 detachAll has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  static detachAll(container = document.body) {
                    const selector = this.DOMDetachSelector || this.DOMAttachSelector;
                    if (process.env.NODE_ENV !== 'production') {
                      if (!selector) {
                        // eslint-disable-next-line quotes
                Severity: Minor
                Found in vj4/ui/components/DOMAttachedObject.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 mapDispatchToProps has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                const mapDispatchToProps = dispatch => ({
                  handleChange(id, value) {
                    if (id === null) {
                      return;
                    }
                Severity: Minor
                Found in vj4/ui/components/messagepad/MessagePadInputContainer.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 scrollToViewport has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                function scrollToViewport() {
                  const BOUND_TOP = 60;
                  const BOUND_BOTTOM = 20;
                  const node = $('.messagepad')[0];
                  if (node.offsetHeight + BOUND_TOP + BOUND_BOTTOM < window.innerHeight) {
                Severity: Minor
                Found in vj4/ui/components/messagepad/reducers/activeId.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 post has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  post(url, dataOrForm = {}, options = {}) {
                    let postData;
                    if (dataOrForm instanceof jQuery && dataOrForm.is('form')) {
                      // $form
                      postData = dataOrForm.serialize();
                Severity: Minor
                Found in vj4/ui/utils/request.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 can_view has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                  def can_view(self, udoc, key):
                    privacy = udoc.get('show_' + key, next(iter(setting.SETTINGS_BY_KEY['show_' + key].range)))
                    return udoc['_id'] == self.user['_id'] \
                           or (privacy == constant.setting.PRIVACY_PUBLIC and True) \
                           or (privacy == constant.setting.PRIVACY_REGISTERED_ONLY
                Severity: Minor
                Found in vj4/handler/user.py - 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 reducer has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                export default function reducer(state = {
                  rows: [],
                  items: {},
                }, action) {
                  switch (action.type) {
                Severity: Minor
                Found in vj4/ui/components/scratchpad/reducers/records.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 _parse_dag_json has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def _parse_dag_json(dag):
                  try:
                    dag = json.decode(dag)
                  except decoder.JSONDecodeError:
                    raise error.ValidationError('dag') from None
                Severity: Minor
                Found in vj4/handler/training.py - 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 _get_exist_node has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                def _get_exist_node(nodes, node_name):
                  for category in nodes.values():
                    assert type(category) is list
                    for node in category:
                      if node['name'] == node_name:
                Severity: Minor
                Found in vj4/model/adaptor/discussion.py - 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 hotkeyPage has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                Open

                const hotkeyPage = new AutoloadPage('hotkeyPage', () => {
                  $(document).on('keydown', ev => {
                    const hotkey = ['alt', 'ctrl', 'shift'].filter(modifyKey => ev[`${modifyKey}Key`]);
                    if (ev.metaKey && !ev.ctrlKey) {
                      hotkey.push('ctrl');
                Severity: Minor
                Found in vj4/ui/components/hotkey/hotkey.page.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

                Severity
                Category
                Status
                Source
                Language