Showing 254 of 254 total issues

Avoid too many return statements within this function.
Open

    return start1on1(user, targetUserGId, targetUserGId.isMASUser ? 'mas' : network);
Severity: Major
Found in server/controllers/request.js - About 30 mins to fix

    Avoid too many return statements within this function.
    Open

      return { status: 'OK' };
    Severity: Major
    Found in server/controllers/request.js - About 30 mins to fix

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

        async function renderForm() {
          await ctx.render('register-reset', {
            page: 'register',
            title: 'Register',
            registrationForm: form.toHTML()
      Severity: Minor
      Found in server/controllers/register.js and 1 other location - About 30 mins to fix
      server/controllers/register.js on lines 202..208

      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

        async function renderForm() {
          await ctx.render('register-ext', {
            page: 'register',
            title: 'Register',
            registrationForm: form.toHTML()
      Severity: Minor
      Found in server/controllers/register.js and 1 other location - About 30 mins to fix
      server/controllers/register.js on lines 255..261

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

        async verifyPassword(password) {
          const encryptedPassword = this.get('password');
          const encryptionMethod = this.get('passwordType');
      
          if (!encryptedPassword) {
      Severity: Minor
      Found in server/models/user.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 setGroupMembers has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.setGroupMembers = async function setGroupMembers(conversation, newMembersHash) {
        const oldMembers = await ConversationMember.find({ conversationId: conversation.id });
      
        for (const oldMember of oldMembers) {
          if (!Object.keys(newMembersHash).some(newMember => newMember === oldMember.gIdString)) {
      Severity: Minor
      Found in server/services/conversations.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 init has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.init = async function init(user, session, maxBacklogLines, cachedUpto) {
        await settingsService.sendUpdateSettings(user, session.id);
        await friendsService.sendUpdateFriends(user, session.id);
        await friendsService.sendConfirmFriends(user, session.id);
        await friendsService.informStateChange(user, 'login');
      Severity: Minor
      Found in server/services/session.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 findOrCreate1on1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.findOrCreate1on1 = async function findOrCreate1on1(user, peerUserGId, network) {
        assert(user && peerUserGId && network);
      
        let conversation = null;
        const userMembers = await ConversationMember.find({ userGId: user.gIdString });
      Severity: Minor
      Found in server/services/conversations.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 didInsertElement has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

        didInsertElement() {
          this.sendAction('register', this);
          this.set('elementInserted', true);
      
          this.$messagePanel = this.$('.window-messages');
      Severity: Minor
      Found in client/app/pods/components/discussion-window/component.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 createExt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      exports.createExt = async function createExt(ctx) {
        const form = await decodeForm(ctx.req, registrationFormExt);
      
        async function renderForm() {
          await ctx.render('register-ext', {
      Severity: Minor
      Found in server/controllers/register.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 authExt has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      async function authExt(openidId, oauthId, profile, done) {
        let user = null;
      
        if (oauthId) {
          user = await User.findFirst({ extAuthId: oauthId });
      Severity: Minor
      Found in server/lib/passport.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 start1on1 has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      async function start1on1(user, targetUserGId, network) {
        let selectedNetwork = network;
      
        if (!targetUserGId || !targetUserGId.valid) {
          return { status: 'ERROR', errorMsg: 'Malformed request.' };
      Severity: Minor
      Found in server/controllers/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 processDisconnected has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      async function processDisconnected({ userId, network, reason }) {
        const user = await User.fetch(userId);
        const networkInfo = await findOrCreateNetworkInfo(user, network);
        const previousState = networkInfo.get('state');
      
      
      Severity: Minor
      Found in server/backends/irc/controller.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 Window has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
      Open

      const Window: FunctionComponent<WindowProps> = ({ window, height = 100, singleWindowMode }: WindowProps) => {
        const { windowStore } = useContext(ServerContext);
        const [isMoving, setIsMoving] = useState<boolean>(false);
        const navigate = useNavigate();
      
      
      Severity: Minor
      Found in new-client/src/components/Window.tsx - 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