question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Put a hardline between "StringLiteral" + "StringLiteral"

See original GitHub issue

Right now

    console.error(
      'In order to use ' + prompt + ', you need to configure a ' +
      'few environment variables to be able to commit to the ' +
      'repository. Follow those steps to get you setup:\n' +
      '\n' +
      'Go to https://github.com/settings/tokens/new\n' +
      ' - Fill "Token description" with "' + prompt + ' for ' +
        repoSlug + '"\n' +
      ' - Check "public_repo"\n' +
      ' - Press "Generate Token"\n' +
      '\n' +
      'In a different tab, go to https://travis-ci.org/' +
        repoSlug + '/settings\n' +
      ' - Make sure "Build only if .travis.yml is present" is ON\n' +
      ' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' +
        'account you generated the token with. Press "Add"\n' +
      '\n' +
      'Once this is done, commit anything to the repository to restart ' +
        'Travis and it should work :)'
    );

gets printed as

    console.error(
      "In order to use " +
        prompt +
        ", you need to configure a " +
        "few environment variables to be able to commit to the " +
        "repository. Follow those steps to get you setup:\n" +
        "\n" +
        "Go to https://github.com/settings/tokens/new\n" +
        ' - Fill "Token description" with "' +
        prompt +
        " for " +
        repoSlug +
        '"\n' +
        ' - Check "public_repo"\n' +
        ' - Press "Generate Token"\n' +
        "\n" +
        "In a different tab, go to https://travis-ci.org/" +
        repoSlug +
        "/settings\n" +
        ' - Make sure "Build only if .travis.yml is present" is ON\n' +
        ' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' +
        'account you generated the token with. Press "Add"\n' +
        "\n" +
        "Once this is done, commit anything to the repository to restart " +
        "Travis and it should work :)"
    );

which breaks on every single + which makes the code harder to read.

One pattern that we can extract is that if you have “string” + “string”, it likely means that there was a \n there originally. So, if we would reformat the code as

group("In order to use " + prompt + ", you need to configure a " +)
group("few environment variables to be able to commit to the " +)
group("repository. Follow those steps to get you setup:\n" +)
group("\n" +)
group("Go to https://github.com/settings/tokens/new\n" +)
group(' - Fill "Token description" with "' + prompt + " for " + repoSlug + '"\n' +)
group(' - Check "public_repo"\n' +)
group(' - Press "Generate Token"\n' +)
group("\n" +)
group("In a different tab, go to https://travis-ci.org/" + repoSlug + "/settings\n" +)
group(' - Make sure "Build only if .travis.yml is present" is ON\n' +)
group(' - Fill "Name" with "GITHUB_USER" and "Value" with the name of the ' +)
group('account you generated the token with. Press "Add"\n' +)
group("\n" +)
group("Once this is done, commit anything to the repository to restart " +)
group("Travis and it should work :)")

that would lead to a better output than breaking on every single +

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

4reactions
vjeuxcommented, Jan 27, 2017
0reactions
vjeuxcommented, Mar 1, 2017

Closing this as I don’t think that this is the right fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between String literal and New String object in ...
The String class or java.lang.String is a special class in Java API and has so many special behaviors which are not obvious to...
Read more >
c# - How to insert newline in string literal?
In .NET I can provide both \r or \n string literals, but there is a way to insert something like "new line" special...
Read more >
String literal
Explanation. 1) Ordinary string literal. The type of an unprefixed string literal is const char[N], where N is the size of the string...
Read more >
String literals
A string literal contains a sequence of characters or escape sequences enclosed in double quotation mark symbols. A string literal with the prefix...
Read more >
Verbatim text - @ in variables, attributes, and string literals
The @ character in this instance defines a verbatim string literal. Simple escape sequences (such as "\\" for a backslash), hexadecimal escape ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found