koki-develop/qiita-cli

View on GitHub

Showing 26 of 26 total issues

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

func (f *String) AddTo(cmds ...*cobra.Command) {
    for _, cmd := range cmds {
        if f.ShortName != "" {
            cmd.Flags().StringVarP(&f.value, f.Name, f.ShortName, f.Default, f.Description)
        } else {
Severity: Major
Found in internal/flags/flags.go and 3 other locations - About 1 hr to fix
internal/flags/flags.go on lines 70..83
internal/flags/flags.go on lines 98..111
internal/flags/flags.go on lines 126..139

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 187.

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 4 locations. Consider refactoring.
Open

func (f *Int) AddTo(cmds ...*cobra.Command) {
    for _, cmd := range cmds {
        if f.ShortName != "" {
            cmd.Flags().IntVarP(&f.value, f.Name, f.ShortName, f.Default, f.Description)
        } else {
Severity: Major
Found in internal/flags/flags.go and 3 other locations - About 1 hr to fix
internal/flags/flags.go on lines 42..55
internal/flags/flags.go on lines 98..111
internal/flags/flags.go on lines 126..139

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 187.

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 4 locations. Consider refactoring.
Open

func (f *StringSlice) AddTo(cmds ...*cobra.Command) {
    for _, cmd := range cmds {
        if f.ShortName != "" {
            cmd.Flags().StringSliceVarP(&f.value, f.Name, f.ShortName, f.Default, f.Description)
        } else {
Severity: Major
Found in internal/flags/flags.go and 3 other locations - About 1 hr to fix
internal/flags/flags.go on lines 42..55
internal/flags/flags.go on lines 70..83
internal/flags/flags.go on lines 98..111

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 187.

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 4 locations. Consider refactoring.
Open

func (f *Bool) AddTo(cmds ...*cobra.Command) {
    for _, cmd := range cmds {
        if f.ShortName != "" {
            cmd.Flags().BoolVarP(&f.value, f.Name, f.ShortName, f.Default, f.Description)
        } else {
Severity: Major
Found in internal/flags/flags.go and 3 other locations - About 1 hr to fix
internal/flags/flags.go on lines 42..55
internal/flags/flags.go on lines 70..83
internal/flags/flags.go on lines 126..139

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 187.

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 init has 73 lines of code (exceeds 50 allowed). Consider refactoring.
Open

func init() {
    /*
     * version
     */
    if version == "" {
Severity: Minor
Found in cmd/qiita/root.go - About 1 hr to fix

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

    var itemsCreateCmd = &cobra.Command{
        Use:   "create",
        Short: "Create an item",
        Long:  "Create an item.",
        Args:  cobra.ExactArgs(0),
    Severity: Major
    Found in cmd/qiita/items.go and 1 other location - About 1 hr to fix
    cmd/qiita/items.go on lines 106..129

    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 169.

    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

    var itemsUpdateCmd = &cobra.Command{
        Use:   "update [id]",
        Short: "Update an item",
        Long:  "Update an item.",
        Args:  cobra.MaximumNArgs(1),
    Severity: Major
    Found in cmd/qiita/items.go and 1 other location - About 1 hr to fix
    cmd/qiita/items.go on lines 81..104

    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 169.

    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

    var itemsListCmd = &cobra.Command{
        Use:   "list",
        Short: "List own items",
        Long:  "List own items.",
        Args:  cobra.ExactArgs(0),
    Severity: Major
    Found in cmd/qiita/items.go and 1 other location - About 1 hr to fix
    cmd/qiita/items.go on lines 176..196

    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 154.

    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

    var itemsPushCmd = &cobra.Command{
        Use:   "push [files]",
        Short: "Upload items",
        Long:  "Upload items.",
        Args:  cobra.MinimumNArgs(1),
    Severity: Major
    Found in cmd/qiita/items.go and 1 other location - About 1 hr to fix
    cmd/qiita/items.go on lines 38..58

    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 154.

    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

    var itemsGetCmd = &cobra.Command{
        Use:   "get [id]",
        Short: "Get an item",
        Long:  "Get an item.",
        Args:  cobra.ExactArgs(1),
    Severity: Major
    Found in cmd/qiita/items.go and 1 other location - About 1 hr to fix
    cmd/qiita/items.go on lines 131..150

    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 149.

    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

    var itemsDeleteCmd = &cobra.Command{
        Use:   "delete [ids]",
        Short: "Delete an item",
        Long:  "Delete an item.",
        Args:  cobra.MinimumNArgs(1),
    Severity: Major
    Found in cmd/qiita/items.go and 1 other location - About 1 hr to fix
    cmd/qiita/items.go on lines 60..79

    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 149.

    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

    Method CLI.ItemsPull has a Cognitive Complexity of 25 (exceeds 20 allowed). Consider refactoring.
    Open

    func (c *CLI) ItemsPull(params *ItemsPullParameters) error {
        all := *params.FlagAll.Get(c.command, true)
        if all && len(params.Args) > 0 {
            return ErrIDsWithAll
        }
    Severity: Minor
    Found in internal/cli/items.go - About 1 hr 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 Configure has 8 return statements (exceeds 4 allowed).
    Open

    func Configure(params *ConfigureParameters) error {
        cfg, err := config.Load()
        if err != nil {
            cfg = &config.Config{}
        }
    Severity: Major
    Found in internal/cli/configure.go - About 50 mins to fix

      Method CLI.ItemsPull has 8 return statements (exceeds 4 allowed).
      Open

      func (c *CLI) ItemsPull(params *ItemsPullParameters) error {
          all := *params.FlagAll.Get(c.command, true)
          if all && len(params.Args) > 0 {
              return ErrIDsWithAll
          }
      Severity: Major
      Found in internal/cli/items.go - About 50 mins to fix

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

        func (cl *Client) CreateItem(params *CreateItemParameters) (Item, error) {
            req, err := cl.newRequest(http.MethodPost, "items", nil, params)
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in internal/qiita/items.go and 2 other locations - About 45 mins to fix
        internal/qiita/items.go on lines 14..26
        internal/qiita/items.go on lines 33..45

        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 116.

        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 3 locations. Consider refactoring.
        Open

        func (cl *Client) ListAuthenticatedUserItems(p *ListAuthenticatedUserItemsParameters) (Items, error) {
            req, err := cl.newRequest(http.MethodGet, "authenticated_user/items", p, nil)
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in internal/qiita/items.go and 2 other locations - About 45 mins to fix
        internal/qiita/items.go on lines 14..26
        internal/qiita/items.go on lines 69..81

        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 116.

        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 3 locations. Consider refactoring.
        Open

        func (cl *Client) ListItems(p *ListItemsParameters) (Items, error) {
            req, err := cl.newRequest(http.MethodGet, "items", p, nil)
            if err != nil {
                return nil, err
            }
        Severity: Major
        Found in internal/qiita/items.go and 2 other locations - About 45 mins to fix
        internal/qiita/items.go on lines 33..45
        internal/qiita/items.go on lines 69..81

        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 116.

        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

            RunE: func(cmd *cobra.Command, args []string) error {
                c, err := newCLI(cmd, flagItemsColumns)
                if err != nil {
                    return err
                }
        Severity: Minor
        Found in cmd/qiita/items.go and 1 other location - About 45 mins to fix
        cmd/qiita/items.go on lines 202..217

        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 115.

        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

            RunE: func(cmd *cobra.Command, args []string) error {
                c, err := newCLI(cmd, nil)
                if err != nil {
                    return err
                }
        Severity: Minor
        Found in cmd/qiita/items.go and 1 other location - About 45 mins to fix
        cmd/qiita/items.go on lines 20..35

        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 115.

        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 WriteMarkdown has 7 return statements (exceeds 4 allowed).
        Open

        func WriteMarkdown(w io.Writer, md string, frontMatter interface{}) error {
            y, err := yaml.Marshal(frontMatter)
            if err != nil {
                return err
            }
        Severity: Major
        Found in internal/util/markdown.go - About 45 mins to fix
          Severity
          Category
          Status
          Source
          Language