Git Product home page Git Product logo

popularconvention's Introduction

Popular Convention on Github

analyzing code convention from github commits for Github data challenge II

You can see Here.

Getting Started

npm install
$(npm bin)/bower install
$(npm bin)/coffee server.coffee --nodejs
open http://localhost:8020/popularconvention

Tests

npm run test
$(npm bin)/grunt test

Requirement

  • Node.js
  • CoffeeScript
  • MongoDB 2.4 with MONGODB_HOST and MONGODB_PORT environment variables set (ex: export MONGODB_HOST=127.0.0.1; export MONGODB_PORT=27017)
  • GitHub tokens (see https://github.com/settings/applications/new) - save to github.json in .tokens directory

Docker

This project is dockerized.

Run mongodb first

docker run --name mongodb -d outsideris/popularconvention-mongodb:1.0

Then, run popular-convention.

docker run -d -p 8020:8020 --link mongodb:mongodb -e "MONGODB_HOST=mongodb" outsideris/popularconvention:1.1

License

Copyright (c) 2017 "Outsider" Jeonghoon Byun Licensed under the MIT license.

popularconvention's People

Contributors

akkartik avatar brendanlong avatar caseyscarborough avatar chrismissal avatar hanksudo avatar konklone avatar lewis-od avatar outsideris avatar razzfox avatar seanponeil avatar tkrotoff avatar ttamminen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

popularconvention's Issues

Popular web languages

I think it would be interesting to see the most popular web languages in there, since their popularity makes it kind of a free-for-all when it comes to coding conventions.

In order of priority, in my opinion:

  1. CSS
  2. HTML
  3. PHP

Languages like Ruby and Python might be less interesting because the languages carry conventions by design.

PS: amazing concept, really. Thanks for putting it online!

Javascript space after anonymous functions

I believe that JSLint recommends:

function foo() {
    [function body]
}

or:

var foo = function () {
    [function body]
}

The report covers the first case but not the second. Should there be a space after function before the brackets when defining an anonymous function?

C# convention - private field naming

I'd love to see how people name the private fields in classes. Especially the underscore prefix.
fex.
private int age;
private string _firstName;

js: trailing semicolon vs. no semicolon

I think that it would be really interesting to compare trailing semicolon vs. no semicolon, especially considering the debate in standard/standard#5.

Personally, I use popular convention whenever I don't have a really strong opinion with good arguments. The only argument for not putting semicolons seems to be "because you don't have to" (which of course can be enough of an argument).

Curly braces

I'd love to see the split of code with curly braces on the same line as functions or conditionals versus on the next line. (I'm a JavaScript dev, but seems like it would work in a lot of languages.)

Same line:

function foo() {
  ...
}

Next line:

function foo()
{
  ...
}

semicolon use in javascript

popular convention and recomendation in many docs seems to be to always put a semicolon at the end of statements in javascript. but it is by no means required, so it would be nice to see real statistics, how much code is out there that does not put semicolons everywhere.

similar cases might exist in other languages, eg python and ruby (and it looks like scala too) use the semicolon to seperate mutiple statements on one line. so optional semicolons could be found there too (however unlikely)

Tab as spaces size

Might be a little difficult to infer but it would be great to have this as a metric, e.g.

2 spaces

function foo() {
  return "bar";
}

4 spaces

function foo() {
    return "bar";
}

more than 4 spaces

function foo() {
      return "bar";
}

Confusing description

c# :: Constant Name

Constant name is neither all caps and pascal cased ref

😕 I'm not sure what this is going for as it lists snake/pascal case in the example. Could this maybe be worded deifferently?

PHP: assignment and array alignment

We, developers, get into flamewars over whether to align array structure and variable assignments. Statistics of whether statements are aligned or not would be very interesting.

In ONGR Strict Standards (Squiz based, PSR-2 compatible) we forced unaligned statements, because of the argument that one element might git diff a lot of neighbourghing lines.

Aligned code example we dislike:

$garry            = 'red';
$longVariableName = 'orange';
$blue             = 'green';

Scala?

I was interested to see the Scala analysis. But when you press that button, it just shows Ruby code. (the Python button seems to show the identical Ruby results)

Constants in Java are static final, not just final

A constant in Java, where the convention is usually to use all caps with underscores is declared static final, e.g.

static final String MY_CONSTANT = "foo";

Awkwardly, the static and final keywords can be in either order, and there can also be other keywords before the variable's type. For example, the following is legal, although unconventional, Java:

final public static String MY_CONSTANT = "foo";

There is, however, a recommended modifier ordering : public, protected, private, static, final, transient, volatile. final and volatile are mutually exclusive so you can ignore volatile in this context.

Ruby tab's example

It should be something like(missing "end", and no need for ":" after parenthesis):

def long_function_name(var_one)
    print(var_one)
end

not this( from python):

def long_function_name(var_one):
    print(var_one)

ps. sorry if I wrote this in wrong place. I'm not that good with github.

Loading wrong langauges

What I click vs what is loading:
JS - Python
Java - Scala
Python - Java
Scala - Scala (yeah!)

I'm getting the same thing on FF 21.0 and Chromium on Mac. According to my console, when I click the buttons it is GETting the correct URLs for each language, however.

Improving Python examples

One quick look at the Python code samples shows they could be further improved. I forked the repo intending to fix them right away, then I of course realized that things won't be so simple so I'm opening this discussion here.

  1. The convention for indenting Python actually uses 4 spaces, so how about the examples used 4 spaces and an 8-space-wide tab instead of the current 2/4?
  2. Dividing chars per line into 80/100/100+ (or 80/100/120/120+) looks a bit better to me than 80/120/150. I tried to make up with a 150-char Python line so I could then make examples of it formatted for shorter line lengths, however I couldn't come up with one off the top of my head so I'm open to suggestions. If you could provide an example that the script has already encountered in the wild, that would be helpful.
  3. "Imports on the same line vs imports on separate lines" would be a more informative metric if it also took into account from X import Y, Z vs from X import Y; from X import Z, as imports via import and imports via from ... import are two different cases which I imagine are styled differently by different authors.
  4. Some of the examples for the "extraneous whitespace" metric look a bit far out, I can say I've hardly encountered things like function (params) or list [key] - and you've forgotten to add long_variable to the extraneous whitespace example so the x = example kind of misses the point.
  5. Also I just wanted to say that this is an awesome project! Keep up the good work :)

PHP

Please consider adding PHP

Ruby defArgs omit regex actually includes no-arg methods in omit

irb(main):001:0> "def foo" =~ /^[\s\t]*def\s+\w+\s*[^()]*(#+.*)*$/
=> 0

So we need a \w in there somewhere, how about:

/^[\s\t]*def\s+\w+\s+\w[^()]*(#+.*)*$/

Seems to work better:

irb(main):006:0> "def foo" =~ /^[\s\t]*def\s+\w+\s+\w[^()]*(#+.*)*$/
=> nil
irb(main):007:0> "def foo(a, b)" =~ /^[\s\t]*def\s+\w+\s+\w[^()]*(#+.*)*$/
=> nil
irb(main):008:0> "def foo a, b" =~ /^[\s\t]*def\s+\w+\s+\w[^()]*(#+.*)*$/
=> 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.