Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCop179 false alarm #263

Open
sungam3r opened this issue Jan 19, 2019 · 11 comments
Open

GCop179 false alarm #263

sungam3r opened this issue Jan 19, 2019 · 11 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@sungam3r
Copy link
Contributor

 internal class Formatter
    {
        public static void Format(string name)
        {
            Console.WriteLine($"{name,10}"); // OK
        }
    }
 internal class Formatter
    {
        public static void Format(string name)
        {
            Console.WriteLine($"{name,11}"); // GCop179	Do not hardcode numbers, strings or other values. Use constant fields, enums, config files or database as appropriate.	
        }
    }

It seems to me that the rule should not be applied to formatting strings.

@Karvan Karvan added this to the Release 1.0.7 milestone Jan 21, 2019
@Foroughi Foroughi self-assigned this Feb 20, 2019
@Foroughi
Copy link
Contributor

Foroughi commented Feb 20, 2019

@sungam3r The reason why GCop is not showing any warning for the first sample is b/c some of the constant values which are listed below have been excluded intentionally. But I managed the rule not kick in for interpolated string texts.

@Karvan Please confirm i did the right thing

"-2", "-1", "0", "1", "2", "3", "4", "5", "12", "1024", "true", "false", "10", "100", "0.1", "0.5", "0.01", "0.001", "0.0001", "0.00001", "1000", "360"

@sungam3r
Copy link
Contributor Author

Also this:

#pragma warning disable 618 // GCop179	Do not hardcode numbers, strings or other values. Use constant fields, enums, config files or database as appropriate.

@marjanjavid
Copy link
Collaborator

@Foroughi This rule still have the previous problem on GCop2.6.1-rc2

@Karvan
Copy link
Collaborator

Karvan commented Dec 23, 2019

@azadimehdi we need to stop kicking GCop179 when we see it's commented out or start with # like this example.

#pragma warning disable 618 // GCop179 Do not hardcode numbers, strings or other values. Use constant fields, enums, config files or database as appropriate.

@azadimehdi
Copy link

@Karvan This issue has already been solved.

@sungam3r
Copy link
Contributor Author

In what release version?

@Karvan
Copy link
Collaborator

Karvan commented Jan 2, 2020

@sungam3r It should be resolved in the latest version which is 2.6.2-rc1

@Karvan Karvan closed this as completed Jan 2, 2020
@sungam3r
Copy link
Contributor Author

sungam3r commented Jan 2, 2020

Nope. This issue still exists.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp2.2</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="GCop.All.Geeks" Version="2.6.2-rc.1" />
  </ItemGroup>
</Project>
using System;

namespace ConsoleApp10
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
        }
    }

    internal class Formatter
    {
        public static void Format(string name)
        {
            Console.WriteLine($"{name,11}"); // Warning	GCop179	Do not hardcode numbers, strings or other values. Use constant fields, enums, config files or database as appropriate.	
        }
    }
}

@Karvan
Copy link
Collaborator

Karvan commented Jan 2, 2020

@azadimehdi could you please have another look into that.

@sungam3r thank you for updating this one. could you please let me know which version of GCop.Common have you installed on your project? if that's 2.6.2-rc.1 then we definitely should be able to replicate that.

@Karvan Karvan reopened this Jan 2, 2020
@Karvan Karvan added the bug Something isn't working label Jan 2, 2020
@sungam3r
Copy link
Contributor Author

sungam3r commented Jan 2, 2020

@sungam3r
Copy link
Contributor Author

sungam3r commented Jan 2, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants