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

Puppet incorrectly classified as Pascal #2318

Closed
3flex opened this issue Apr 8, 2015 · 8 comments
Closed

Puppet incorrectly classified as Pascal #2318

3flex opened this issue Apr 8, 2015 · 8 comments

Comments

@3flex
Copy link
Contributor

3flex commented Apr 8, 2015

This file is Puppet code, not Pascal: https://github.com/jfryman/puppet-nginx/blob/master/manifests/init.pp

It might help if a new sample is added which contains class parameters, none of the samples include this:

    # A class with parameters
    class apache ($version = 'latest') {
      package {'httpd':
        ensure => $version, # Using the class parameter from above
        before => File['/etc/httpd.conf'],
      }
      file {'/etc/httpd.conf':
        ensure  => file,
        owner   => 'httpd',
        content => template('apache/httpd.conf.erb'), # Template from a module
      }
      service {'httpd':
        ensure    => running,
        enable    => true,
        subscribe => File['/etc/httpd.conf'],
      }
    }

Example is from https://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html#syntax

Also missing is an example of inheritance which the problem file also uses.

class example (
  $my_param = $example::params::myparam
) inherits example::params {

  notice('This is a test notice')
}

Modified from https://docs.puppetlabs.com/puppet/latest/reference/lang_classes.html#aside-when-to-inherit

@pchaigno
Copy link
Contributor

pchaigno commented Apr 8, 2015

New samples are always welcome!
Do you want to open a pull request? I'm not from GitHub so I won't be able to merge your PR (though it should be merged quickly) but if there's any issue I can help you.

@3flex
Copy link
Contributor Author

3flex commented Apr 8, 2015

So I just drop these into /samples/Puppet, then they'll do their magic?

It would probably be best to have a disambiguation in heuristics.rb but I don't know Pascal nor am I any good with regular expressions.

@3flex
Copy link
Contributor Author

3flex commented Apr 8, 2015

Now I think about it, if someone could help come up with something that detects the first keyword in the file is either class, define or node (ignoring any comments in the preceding lines [i.e. lines that start with #]) then we can say that's Puppet. It would be good enough for most cases.

@pchaigno
Copy link
Contributor

We usually prefer to add heuristic rules if the issue can't be solved only with the Bayesian classifier. We could first try to add new samples and if that doesn't solve it (we'll need incorrectly classified repositories to test it), we can build a new heuristic.

@arfon
Copy link
Contributor

arfon commented Apr 15, 2015

We usually prefer to add heuristic rules if the issue can't be solved only with the Bayesian classifier.

Yes, please add some samples to /samples/Puppet. If this doesn't fix the issue then let's look at adding a heuristic.

@arfon arfon closed this as completed Apr 15, 2015
@3flex
Copy link
Contributor Author

3flex commented Apr 15, 2015

I'm happy to open a PR, can you leave this issue open though? It's not fixed, I'm not sure why it was closed.

@arfon arfon reopened this Apr 15, 2015
@arfon
Copy link
Contributor

arfon commented Apr 15, 2015

Yep, sorry.

@arfon
Copy link
Contributor

arfon commented Aug 4, 2015

This now looks to be fixed. Please feel free to comment/re-open if you're still having problems.

@arfon arfon closed this as completed Aug 4, 2015
@github-linguist github-linguist locked as resolved and limited conversation to collaborators Jun 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants